JavaFX: 导入ikonli-master

JavaFX: 导入ikonli-master

本来先读取文件展示,标签plane显示好看,就看到 Ikonli


JavaFX中文官方网站 社区中找到 Ikonli
Ikonli官网资料
JavaFX: 导入ikonli-master_第1张图片

Maven导入Ikonli


Maven 项目的 pom.xml 中添加:

    <dependencies>
        <dependency>
            <groupId>org.kordamp.ikonligroupId >
            <artifactId>ikonli-javafxartifactId >
            <version>11.3.5version>
        dependency>
    dependencies>
Caused by: java.lang.UnsupportedClassVersionError: org/kordamp/ikonli/javafx/StackedFontIcon has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)

报错我需要降低Ikonli版本或升级JDK版本,查看Ikonli官网资料降低Ikonli版本为2.6.0
JavaFX: 导入ikonli-master_第2张图片

Ikonli中fxml添加到项目中运行

sample.fxml
JavaFX: 导入ikonli-master_第3张图片
降低Ikonli版本为2.6.0,报错崩溃,但更新到JDK11和Ikonli12.0.0依然报该错误,测试屏蔽ikonli控件参数iconLiteral成功,ikonli控件有问题啊~~
JavaFX: 导入ikonli-master_第4张图片JavaFX: 导入ikonli-master_第5张图片

Ikonli查看属性 iconLiteral


既然该项目在Java FX上推荐,继续查看上面错误fxml解析错误,再对照Ikonli官网资料,是缺少资源Icon pack资源,但是没有明确怎么查找。不过Ikonli官网资料相关Icon Packs资源
JavaFX: 导入ikonli-master_第6张图片

例如Win10的Icon Packs资源;pom.xml配置并查看对照表Cheat-Sheet

JavaFX: 导入ikonli-master_第7张图片JavaFX: 导入ikonli-master_第8张图片
sample.fxml文件修改并运行





<GridPane prefHeight="60.0" prefWidth="200.0"
          xmlns:fx="http://javafx.com/fxml">
    <StackedFontIcon GridPane.columnIndex="0" GridPane.rowIndex="0" iconSize="48">
        <FontIcon iconLiteral="win10-alphabetical-sorting" iconColor="red"/>
        <FontIcon iconLiteral="win10-alphabetical-sorting" StackedFontIcon.iconSize="0.5"/>
    StackedFontIcon>
    <StackedFontIcon GridPane.columnIndex="1" GridPane.rowIndex="0" iconSize="48">
        <FontIcon iconLiteral="win10-airport" iconColor="red"/>
        <FontIcon iconLiteral="win10-airport" StackedFontIcon.iconSize="0.5"/>
    StackedFontIcon>
    <StackedFontIcon GridPane.columnIndex="3" GridPane.rowIndex="0" iconSize="48">
        <FontIcon iconLiteral="win10-create-new" iconColor="red"/>
        <FontIcon iconLiteral="win10-create-new" StackedFontIcon.iconSize="0.5"/>
    StackedFontIcon>
    <StackedFontIcon GridPane.columnIndex="4" GridPane.rowIndex="0" iconSize="48">
        <FontIcon iconLiteral="win10-crop" iconColor="red"/>
        <FontIcon iconLiteral="win10-crop" StackedFontIcon.iconSize="0.5"/>
    StackedFontIcon>
    <StackedFontIcon GridPane.columnIndex="5" GridPane.rowIndex="0" iconSize="48">
        <FontIcon iconLiteral="win10-cut" iconColor="red"/>
        <FontIcon iconLiteral="win10-cut" StackedFontIcon.iconSize="0.5"/>
    StackedFontIcon>
    <StackedFontIcon GridPane.columnIndex="6" GridPane.rowIndex="0" iconSize="48">
        <FontIcon iconLiteral="win10-create-new" iconColor="red"/>
        <FontIcon iconLiteral="win10-create-new" StackedFontIcon.iconSize="0.5"/>
    StackedFontIcon>
GridPane>

JavaFX: 导入ikonli-master_第9张图片

你可能感兴趣的:(Java,#,JavaFX,Windows,javafx)