I'm using fontawesomefx-8.9 and I have set their font size to 15px using
.glyph-icon {
-fx-font-size: 15px;
}
Then I have created some FontAwesomeIconViews and embed them in some Buttons(JavaFX).
The issue I had to face is changing fontAwesome icons to a rectangle when hovering mouse over the button.
FXML File is below(FXMLDocument,fxml)
<?xml version="1.0" encoding="UTF-8"?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" stylesheets="@styles.css" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.111" fx:controller="test_fontawesome.FXMLDocumentController">
<children>
<Button fx:id="button" contentDisplay="TOP" layoutX="44.0" layoutY="41.0" onAction="#handleButtonAction" text="Click Me!" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="40.0">
<graphic>
<FontAwesomeIconView fill="BLUE" glyphName="CUT" />
</graphic></Button>
<Label fx:id="label" layoutX="126" layoutY="120" minHeight="16" minWidth="69" />
<Button fx:id="button1" contentDisplay="TOP" layoutX="183.0" layoutY="41.0" onAction="#handleButtonAction" text="Click Me!" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="40.0">
<graphic>
<FontAwesomeIconView fill="BLUE" glyphName="PLUS" />
</graphic>
</Button>
</children>
</AnchorPane>
CSS is file below(styles.css)
.root {
-fx-font-size: 12px ;
}
Just preview it on scene builder, the issue will appear!
If you want the source code, get it from here.