FontAwesomeFX - 仅显示矩形 [英] FontAwesomeFX - only rectangles displayed

查看:450
本文介绍了FontAwesomeFX - 仅显示矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的JavaFX应用程序中使用FontAwesomeFX 8.4,但每个字形都显示为一个矩形(缺少字符字形)。顺便说一句,这就是作者的测试应用程序的样子:





任何想法可能出错?



我在Arch Linux上使用Intellij IDEA。



POM:

 <?xml version =1.0encoding =UTF-8?> ; 
< project xmlns =http://maven.apache.org/POM/4.0.0
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">
< modelVersion> 4.0.0< / modelVersion>

< groupId> de.jensd.fx.glyphs< / groupId>
< artifactId> testapps< / artifactId>
< version> 1.0-SNAPSHOT< / version>

< dependencies>
<依赖>
< groupId> de.jensd< / groupId>
< artifactId> fontawesomefx< / artifactId>
< version> 8.4< / version>
< / dependency>
< / dependencies>

解决方案

这是使用FontAwesomeFX演示应用程序将Intellij Idea与Maven一起使用的分步指南。我只安装了Windows 8.1 x64,但它应该适用于每个操作系统。也许其他人试一试并添加评论。



第1步



创建一个新的类型项目Maven的。如果尚未设置JDK,请选择SDK。不要选择任何原型或不选中从原型创建框。点击下一步。





第2步



给它一个像com.myCompany这样的组ID,并给它一个像fademo这样的工件ID,该版本不相关。点击下一步。





Step3



为其提供项目名称和存储文件的位置。点击下一步。





Step4



这就是新项目的样子。继续下一步。





只需点击启用自动导入即可。继续下一步。





Step6



现在创建一个新的Java类App并复制并粘贴App源的内容。之后,保存新的类。





现在,您可以通过右键单击App.java文件来启动整个FontAwesomeFX演示应用程序。选择运行App.main()。





Step7



这就是Demo App的样子。





源代码



pom.xml的依赖关系



 < dependencies> 
<依赖>
< groupId> de.jensd< / groupId>
< artifactId> fontawesomefx< / artifactId>
< version> 8.4< / version>
< / dependency>
< / dependencies>



App.java



  import de.jensd.fx.glyphs.GlyphsBuilder; 
import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.GlyphsStack;
import de.jensd.fx.glyphs.GlyphsStyle;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView;
import de.jensd.fx.glyphs.weathericons.WeatherIcon;
import de.jensd.fx.glyphs.weathericons.WeatherIconView;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/ **
* @author Jens Deters
* /
公共类应用扩展应用{

@Override
public void start(Stage primaryStage)throws Exception {

VBox root = new VBox();
root.setSpacing(10.0);

Button testButton = new Button();
testButton.getStyleClass()。setAll(exit-button);
GlyphsDude.setIcon(testButton,FontAwesomeIcon.POWER_OFF,6em);

按钮testButton2 = new Button();
testButton2.getStyleClass()。add(alien-button);
GlyphsDude.setIcon(testButton2,WeatherIcon.ALIEN,6em);

FontAwesomeIconView fontAwesomeIcon
= new FontAwesomeIconView(FontAwesomeIcon.AMBULANCE);
fontAwesomeIcon.setStyleClass(blue-icon);
fontAwesomeIcon.setSize(4em);

WeatherIconView weatherIcon1 = new WeatherIconView(WeatherIcon.CLOUD);
weatherIcon1.setStyleClass(blue-icon);
weatherIcon1.setSize(4em);

/ *
* .thumbs-up-icon {
* -glyph-name:THUMBS_UP;
* -glyph-size:6em;
*}
*
* .thumbs-down-icon {
* -glyph-name:THUMBS_DOWN;
* -glyph-size:6em;
*}
* /
FontAwesomeIconView thumbsUpIcon = new FontAwesomeIconView();
thumbsUpIcon.setStyleClass(thumbs-up-icon);

FontAwesomeIconView thumbsDownIcon = new FontAwesomeIconView();
thumbsDownIcon.setStyleClass(thumbs-down-icon);

WeatherIconView weatherIcon2 = new WeatherIconView();
weatherIcon2.setStyleClass(green-icon);
weatherIcon2.setSize(4em);

Text githubLabel = GlyphsDude.createIcon(FontAwesomeIcon.GITHUB);
Text ambulanceLabel
= GlyphsDude.createIcon(FontAwesomeIcon.PLUS_SQUARE_ALT,60.0);
Button starButton
= GlyphsDude.createIconButton(FontAwesomeIcon.STAR,Nice!,48.0,20.0,ContentDisplay.TOP);
Button cloudButton
= GlyphsDude.createIconButton(FontAwesomeIcon.CLOUD,Download);
ToggleButton toggleButton
= GlyphsDude.createIconToggleButton(FontAwesomeIcon.LOCK,Lock,60.0,ContentDisplay.TOP);
Region stackedIcon1
= GlyphsStack.create()。add(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.AMBULANCE).build());

Region stackedIcon2 = GlyphsStack.create()
.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.SQUARE)
.size( 3em)
.styleClass(stack-base)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph (FontAwesomeIcon.STAR)
.size(2em)
.styleClass(stack-top)
.build()
);

Region stackedIcon3 = GlyphsStack.create()
.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.SQUARE)
.style( -fx-font-size:4em; -fx-fill:yellowgreen;)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.APPLE)
.style( - fx-font-size:3em; -fx-fill:white;)
.build()
);

Region stackedIcon4 = GlyphsStack.create()
.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.SQUARE)
.style( -fx-font-size:4em; -fx-fill:yellowgreen;)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.APPLE)
.style( - fx-font-size:3em; -fx-fill:black;)
.build()
);

Region stackedIcon5 = GlyphsStack.create()
.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.BUG)
.style( -fx-font-size:2em; -fx-fill:black;)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.BAN)
.style( - fx-font-size:6em; -fx-fill:red; -fx-opacity:0.5;)
.build()
);

Region stackedIcon6 = GlyphsStack.create()
.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.CIRCLE)
.style( -fx-font-size:10em; -fx-fill:linear-gradient(#70b4e5 0%,#247cbc 70%,#2c85c1 85%);)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.TWITTER)
.style( - fx-font-size:6em; -fx-fill:white; )
.build()
);

Region stackedIcon7 = GlyphsStack.create()
.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.CIRCLE)
.style( -fx-font-size:10em; -fx-fill:linear-gradient(#70b4e5 0%,#247cbc 70%,#2c85c1 85%);)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.BITBUCKET)
.style( - fx-font-size:6em;
+ - fx-fill:线性渐变(#ffffff,#d2d2d2);
+ - fx-effect:dropshadow(one-pass-box,rgba(0,0,0,0.8),4,0.0, 1,1);)
.build()
);
HBox stackIconBox1 = new HBox();
stackIconBox1.setSpacing(5.0);
stackIconBox1.setPadding(new Insets(10.0));
stackIconBox1.getChildren()。addAll(stackedIcon1,stackedIcon2,stackedIcon3,stackedIcon4,stackedIcon5,stackedIcon6,stackedIcon7);

Region iconStack1 = GlyphsStack.create()
.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.CIRCLE)
.style( -fx-font-size:12em; -fx-fill:linear-gradient(#70b4e5 0%,#247cbc 70%,#2c85c1 85%);)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.BITBUCKET)
.style( - fx-font-size:6em;
+ - fx-fill:线性渐变(#ffffff 0%,#d2d2d2);
+ - fx-effect:dropshadow(one-pass-box,rgba(0,0,0,0.8),4, 0.0,1,1);)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.BAN)
.style( - fx-font-size:12em; -fx-fill:红色; -fx-opacity:0.5;)
.build()
);

Region iconStack3 = GlyphsStack.create()
.add(GlyphsBuilder.create( FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.CIRCLE)
.size(12em)
.style( - fx-fill:linear-gradient(#70b4e5 0%,#247cbc) 70%,#2c85c1 85%);)
.build()

.add(GlyphsBuilder.create(WeatherIconView.class)
.glyph(WeatherIcon.RAIN)
.size(4em)
.style( - fx-fill:linear-gradient(#ffffff 0%,#d2d2d2);
+ - fx-effect:dropshadow (one-pass-box,rgba(0,0,0,0.8),4,0.0,1,1);)
.build()

.add(GlyphsBuilder.create(FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.BAN)
.size(12em)
.style( - fx-fill:red; -fx-opacity:0.5;)
.build()
);

Region iconStack4 = GlyphsStack.create()
.addAll(GlyphsBuilder.create( FontAwesomeIconView.class)
.glyph(FontAwesomeIcon.CIRCLE)
.size(12em)
.style( - fx-fill:linear-gradient(#70b4e5 0%,#247cbc) 70%,#2c85c1 85%);)
.build(),
GlyphsBuilder.create(WeatherIconView.class)
.glyph(WeatherIcon.SUNRISE)
.size( 4em)
.style( - fx-fill:线性渐变(橙色0%,黑暗);
+ - fx-effect:dropshadow(one-pass-box,rgba( 0,0,0,0.8),4,0.0,1,1);)
.build()
);

HBox stackIconBox2 = new HBox();
stackIconBox2.setSpacing(5.0);
stackIconBox2.setPadding(new Insets(10.0));
stackIconBox2.getChildren()。addAll(iconStack1,iconStack3,iconStack4);

HBox basicIconBox = new HBox();
basicIconBox.setAlignment(Pos.CENTER);
basicIconBox.setSpacing(20.0);
basicIconBox.getChildren()。addAll(thumbsUpIcon,thumbsDownIcon,fontAwesomeIcon,weatherIcon1,weatherIcon2,testButton,testButton2,githubLabel,ambulanceLabel);

root.getChildren()。addAll(createMenubar(),basicIconBox,starButton,cloudButton,toggleButton,stackIconBox1,stackIconBox2);

场景场景=新场景(根);
scene.getStylesheets()。addAll(GlyphsStyle.DEFAULT.getStylePath());

primaryStage.setScene(scene);
primaryStage.setTitle(FontAwesomeFX demo);
primaryStage.show();

}

private MenuBar createMenubar(){

MenuBar menuBar = new MenuBar();

MenuItem openItem = new MenuItem(Open);
GlyphsDude.setIcon(openItem,FontAwesomeIcon.FILE);
MenuItem saveItem = new MenuItem(Save);
GlyphsDude.setIcon(saveItem,FontAwesomeIcon.DOWNLOAD);
MenuItem saveAsItem = new MenuItem(另存为...);
GlyphsDude.setIcon(saveAsItem,FontAwesomeIcon.DOWNLOAD);
MenuItem exitItem = new MenuItem(Exit);
GlyphsDude.setIcon(exitItem,FontAwesomeIcon.SIGN_OUT);

菜单menuFile =新菜单(文件);
menuFile.getItems()。add(openItem);
menuFile.getItems()。add(saveItem);
menuFile.getItems()。add(saveAsItem);
menuFile.getItems()。add(new SeparatorMenuItem());
menuFile.getItems()。add(exitItem);

菜单menuEdit =新菜单(编辑);
菜单menuView =新菜单(查看);

menuBar.getMenus()。addAll(menuFile,menuEdit,menuView);

返回menuBar;
}

public static void main(String [] args){
System.setProperty(prism.lcdtext,false);
launch(args);
}
}



更新



在安装了Oracle JDK 1.8.0_45的Ubuntu 15.04 x64中完成相同的操作并且它可以工作:




I'm trying to use FontAwesomeFX 8.4 in my JavaFX app, but every glyph is displayed as a rectangle (the "missing character" glyph). By the way, this is how the test app from the author looks like:

Any ideas what could be wrong?

I'm on Arch Linux and using Intellij IDEA.

POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.jensd.fx.glyphs</groupId>
<artifactId>testapps</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>de.jensd</groupId>
        <artifactId>fontawesomefx</artifactId>
        <version>8.4</version>
    </dependency>
</dependencies>

解决方案

This is an Step by Step Guide for using Intellij Idea with Maven using the FontAwesomeFX Demo App. I only have a Windows 8.1 x64 installation, but it should work on every OS. Maybe other people give it a try and add a comment.

Step 1

Create a new Project of type Maven. Select the SDK if none JDK was already set. do not select any archetype or do not check the "Create from archetype" box. Click next.

Step 2

Give it a group-id like "com.myCompany" and give it an artifact-id like "fademo" the version is not relevant. Click next.

Step3

Give it a project name and a location to store files. Click next.

Step4

This is how the new project looks like. Move on with next step.

Step5

Now copy the dependency into your pom.xml. Afer you have saved the file, there is a display shown in the right upper corner which wanted you to update the maven.

Simply click "Enable Auto-Import". Move on to the next step.

Step6

Now create a new Java class "App" and copy and paste the content of the App source in. After that, save your new class.

Now you are able to start the whole FontAwesomeFX Demo App by right clicking the App.java file and choosing "Run App.main()".

Step7

This is how the Demo App is looking.

Source code

Dependency for pom.xml

<dependencies>
    <dependency>
        <groupId>de.jensd</groupId>
        <artifactId>fontawesomefx</artifactId>
        <version>8.4</version>
    </dependency>
</dependencies>

App.java

import de.jensd.fx.glyphs.GlyphsBuilder;
import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.GlyphsStack;
import de.jensd.fx.glyphs.GlyphsStyle;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView;
import de.jensd.fx.glyphs.weathericons.WeatherIcon;
import de.jensd.fx.glyphs.weathericons.WeatherIconView;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
 * @author Jens Deters
 */
public class App extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {

        VBox root = new VBox();
        root.setSpacing(10.0);

        Button testButton = new Button();
        testButton.getStyleClass().setAll("exit-button");
        GlyphsDude.setIcon(testButton, FontAwesomeIcon.POWER_OFF, "6em");

        Button testButton2 = new Button();
        testButton2.getStyleClass().add("alien-button");
        GlyphsDude.setIcon(testButton2, WeatherIcon.ALIEN, "6em");

        FontAwesomeIconView fontAwesomeIcon
                = new FontAwesomeIconView(FontAwesomeIcon.AMBULANCE);
        fontAwesomeIcon.setStyleClass("blue-icon");
        fontAwesomeIcon.setSize("4em");

        WeatherIconView weatherIcon1 = new WeatherIconView(WeatherIcon.CLOUD);
        weatherIcon1.setStyleClass("blue-icon");
        weatherIcon1.setSize("4em");

    /*
     * .thumbs-up-icon{
     * -glyph-name: "THUMBS_UP";
     * -glyph-size: 6em;
     * }
     *
     * .thumbs-down-icon{
     * -glyph-name: "THUMBS_DOWN";
     * -glyph-size: 6em;
     * }
     */
        FontAwesomeIconView thumbsUpIcon = new FontAwesomeIconView();
        thumbsUpIcon.setStyleClass("thumbs-up-icon");

        FontAwesomeIconView thumbsDownIcon = new FontAwesomeIconView();
        thumbsDownIcon.setStyleClass("thumbs-down-icon");

        WeatherIconView weatherIcon2 = new WeatherIconView();
        weatherIcon2.setStyleClass("green-icon");
        weatherIcon2.setSize("4em");

        Text githubLabel = GlyphsDude.createIcon(FontAwesomeIcon.GITHUB);
        Text ambulanceLabel
                = GlyphsDude.createIcon(FontAwesomeIcon.PLUS_SQUARE_ALT, "60.0");
        Button starButton
                = GlyphsDude.createIconButton(FontAwesomeIcon.STAR, "Nice!", "48.0", "20.0", ContentDisplay.TOP);
        Button cloudButton
                = GlyphsDude.createIconButton(FontAwesomeIcon.CLOUD, "Download");
        ToggleButton toggleButton
                = GlyphsDude.createIconToggleButton(FontAwesomeIcon.LOCK, "Lock", "60.0", ContentDisplay.TOP);
        Region stackedIcon1
                = GlyphsStack.create().add(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.AMBULANCE).build());

        Region stackedIcon2 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.SQUARE)
                                .size("3em")
                                .styleClass("stack-base")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.STAR)
                                .size("2em")
                                .styleClass("stack-top")
                                .build()
                );

        Region stackedIcon3 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.SQUARE)
                                .style("-fx-font-size: 4em; -fx-fill: yellowgreen;")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.APPLE)
                                .style("-fx-font-size: 3em; -fx-fill: white;")
                                .build()
                );

        Region stackedIcon4 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.SQUARE)
                                .style("-fx-font-size: 4em; -fx-fill: yellowgreen;")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.APPLE)
                                .style("-fx-font-size: 3em; -fx-fill: black;")
                                .build()
                );

        Region stackedIcon5 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.BUG)
                                .style("-fx-font-size: 2em; -fx-fill: black;")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.BAN)
                                .style("-fx-font-size: 6em; -fx-fill: red; -fx-opacity: 0.5;")
                                .build()
                );

        Region stackedIcon6 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.CIRCLE)
                                .style("-fx-font-size: 10em; -fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.TWITTER)
                                .style("-fx-font-size: 6em; -fx-fill: white;")
                                .build()
                );

        Region stackedIcon7 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.CIRCLE)
                                .style("-fx-font-size: 10em; -fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.BITBUCKET)
                                .style("-fx-font-size: 6em; "
                                        + "-fx-fill: linear-gradient(#ffffff, #d2d2d2); "
                                        + "-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 4 , 0.0 , 1 , 1 );")
                                .build()
                );
        HBox stackIconBox1 = new HBox();
        stackIconBox1.setSpacing(5.0);
        stackIconBox1.setPadding(new Insets(10.0));
        stackIconBox1.getChildren().addAll(stackedIcon1, stackedIcon2, stackedIcon3, stackedIcon4, stackedIcon5, stackedIcon6, stackedIcon7);

        Region iconStack1 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.CIRCLE)
                                .style("-fx-font-size: 12em; -fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.BITBUCKET)
                                .style("-fx-font-size: 6em; "
                                        + "-fx-fill: linear-gradient(#ffffff 0%, #d2d2d2); "
                                        + "-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 4 , 0.0 , 1 , 1 );")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.BAN)
                                .style("-fx-font-size: 12em; -fx-fill: red; -fx-opacity: 0.5;")
                                .build()
                );

        Region iconStack3 = GlyphsStack.create()
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.CIRCLE)
                                .size("12em")
                                .style("-fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
                                .build()
                )
                .add(GlyphsBuilder.create(WeatherIconView.class)
                                .glyph(WeatherIcon.RAIN)
                                .size("4em")
                                .style("-fx-fill: linear-gradient(#ffffff 0%, #d2d2d2); "
                                        + "-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 4 , 0.0 , 1 , 1 );")
                                .build()
                )
                .add(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.BAN)
                                .size("12em")
                                .style("-fx-fill: red; -fx-opacity: 0.5;")
                                .build()
                );

        Region iconStack4 = GlyphsStack.create()
                .addAll(GlyphsBuilder.create(FontAwesomeIconView.class)
                                .glyph(FontAwesomeIcon.CIRCLE)
                                .size("12em")
                                .style("-fx-fill: linear-gradient(#70b4e5 0%, #247cbc 70%, #2c85c1 85%);")
                                .build(),
                        GlyphsBuilder.create(WeatherIconView.class)
                                .glyph(WeatherIcon.SUNRISE)
                                .size("4em")
                                .style("-fx-fill: linear-gradient(orange 0%, darkred); "
                                        + "-fx-effect: dropshadow( one-pass-box , rgba(0,0,0,0.8) , 4 , 0.0 , 1 , 1 );")
                                .build()
                );

        HBox stackIconBox2 = new HBox();
        stackIconBox2.setSpacing(5.0);
        stackIconBox2.setPadding(new Insets(10.0));
        stackIconBox2.getChildren().addAll(iconStack1, iconStack3, iconStack4);

        HBox basicIconBox = new HBox();
        basicIconBox.setAlignment(Pos.CENTER);
        basicIconBox.setSpacing(20.0);
        basicIconBox.getChildren().addAll(thumbsUpIcon, thumbsDownIcon, fontAwesomeIcon, weatherIcon1, weatherIcon2, testButton, testButton2, githubLabel, ambulanceLabel);

        root.getChildren().addAll(createMenubar(), basicIconBox, starButton, cloudButton, toggleButton, stackIconBox1, stackIconBox2);

        Scene scene = new Scene(root);
        scene.getStylesheets().addAll(GlyphsStyle.DEFAULT.getStylePath());

        primaryStage.setScene(scene);
        primaryStage.setTitle("FontAwesomeFX demo");
        primaryStage.show();

    }

    private MenuBar createMenubar() {

        MenuBar menuBar = new MenuBar();

        MenuItem openItem = new MenuItem("Open");
        GlyphsDude.setIcon(openItem, FontAwesomeIcon.FILE);
        MenuItem saveItem = new MenuItem("Save");
        GlyphsDude.setIcon(saveItem, FontAwesomeIcon.DOWNLOAD);
        MenuItem saveAsItem = new MenuItem("Save As...");
        GlyphsDude.setIcon(saveAsItem, FontAwesomeIcon.DOWNLOAD);
        MenuItem exitItem = new MenuItem("Exit");
        GlyphsDude.setIcon(exitItem, FontAwesomeIcon.SIGN_OUT);

        Menu menuFile = new Menu("File");
        menuFile.getItems().add(openItem);
        menuFile.getItems().add(saveItem);
        menuFile.getItems().add(saveAsItem);
        menuFile.getItems().add(new SeparatorMenuItem());
        menuFile.getItems().add(exitItem);

        Menu menuEdit = new Menu("Edit");
        Menu menuView = new Menu("View");

        menuBar.getMenus().addAll(menuFile, menuEdit, menuView);

        return menuBar;
    }

    public static void main(String[] args) {
        System.setProperty("prism.lcdtext", "false");
        launch(args);
    }
}

Update

Done the same thing in Ubuntu 15.04 x64 with Oracle JDK 1.8.0_45 installed and it works:

这篇关于FontAwesomeFX - 仅显示矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆