我想在项目中使用fontawsome图标。我正在使用JavaFx(java8)和fontawesomefx-8.9库。不幸的是,当我在SceneBuilder的“字形名称”部分中更改图标时,它们不会更改。
我已经将fontawesomefx-8.9.jar集成到我的项目中。之后,我可以在sceneBuilder中使用FontAwsomeIconView。
但是不幸的是,如果我选择其他图标,默认图标不会更改。
主要:
package main;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("freelancerdashboardgui.fxml"));
primaryStage.setTitle("Freelancer Dashboar");
primaryStage.setScene(new Scene(root, 600, 875));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="756.0" prefWidth="1159.0" xmlns="http://javafx.com/javafx/8.0.172-ea" >
<padding>
<Insets left="50.0" />
</padding>
<VBox prefHeight="756.0" prefWidth="276.0" style="-fx-background-color: #202A2F;">
<children>
<Button alignment="BASELINE_LEFT" mnemonicParsing="false" prefHeight="68.0" prefWidth="276.0" stylesheets="@css/styling.css" text="Überblick" textFill="WHITE">
<graphic>
<FontAwesomeIconView fill="WHITE" glyphName="GEAR" text="" />
</graphic>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets left="50.0" />
</padding>
</Button>
<Button alignment="BASELINE_LEFT" mnemonicParsing="false" prefHeight="68.0" prefWidth="276.0" stylesheets="@css/styling.css" text="Kunde einpflegen" textFill="WHITE">
<graphic>
<FontAwesomeIconView fill="WHITE" text="" />
</graphic>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets left="50.0" />
</padding>
</Button>
<Button alignment="BASELINE_LEFT" mnemonicParsing="false" prefHeight="68.0" prefWidth="276.0" stylesheets="@css/styling.css" text="Kunden" textFill="WHITE">
<graphic>
<FontAwesomeIconView fill="WHITE" text="" />
</graphic>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets left="50.0" />
</padding>
</Button>
<Button alignment="BASELINE_LEFT" mnemonicParsing="false" prefHeight="68.0" prefWidth="276.0" stylesheets="@css/styling.css" text="Einstellungen" textFill="WHITE">
<graphic>
<FontAwesomeIconView fill="WHITE" glyphName="address-card" text="" />
</graphic>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets left="50.0" />
</padding>
</Button>
</children>
</VBox>
</AnchorPane>
有人知道这种情况还是我做错了什么?
答案 0 :(得分:0)
只需要清空文本字段就可以了,但是我遇到了同样的问题。