‘Font Awesome’ Icons with JavaFX revisited

Refer for latest updates here.

Hi,
while melting away during the day in the office, it is now cool enough to revisit
FontAwesome and to adjust my little project to support FontAwesome version 3.2.1.

Thus: Major Changes:

  • Added all new version 3.2.1 icons (now 361 icons in total).
  • Removed leading “ICON_” from AwesomeIcon Enum (AwesomeIcon.GEARS instead of AwesomeIcon.ICON_GEARS).
  • Easier usage: Font is automatically loaded. Just use the factory methods provided by the dude.
  • Size parameters are String now to support different values, e.g. “2em”

Usage:

public class App extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
       
     
        Label githubLabel = AwesomeDude.createIconLabel(AwesomeIcon.GITHUB);
        Label ambulanceLabel = AwesomeDude.createIconLabel(AwesomeIcon.AMBULANCE, "60.0");
        Button starButton = AwesomeDude.createIconButton(AwesomeIcon.STAR, "Nice!", "60.0", "20.0", ContentDisplay.TOP);
        Button cloudButton = AwesomeDude.createIconButton(AwesomeIcon.CLOUD, "Download");
        ToggleButton toggleButton = AwesomeDude.createIconToggleButton(AwesomeIcon.LOCK, "Lock", "60.0", ContentDisplay.TOP);

        ToggleButton serverButton = AwesomeDude.createIconToggleButton(AwesomeIcon.DASHBOARD, "Domain", "3em", ContentDisplay.TOP);
        ToggleButton configurationButton = AwesomeDude.createIconToggleButton(AwesomeIcon.GEARS, "Config", "3em", ContentDisplay.TOP);
        ToggleButton settingsButton = AwesomeDude.createIconToggleButton(AwesomeIcon.FILE_TEXT, "Settings", "3em", ContentDisplay.TOP);
        ToggleButton updateButton = AwesomeDude.createIconToggleButton(AwesomeIcon.DOWNLOAD, "Update", "3em", ContentDisplay.TOP);
        ToggleButton aboutButton = AwesomeDude.createIconToggleButton(AwesomeIcon.INFO_SIGN, "About", "3em", ContentDisplay.TOP);

        SegmentedButton segmentedButton = new SegmentedButton(serverButton, configurationButton, settingsButton, updateButton, aboutButton);

        ToggleButton serverButtonBig = AwesomeDude.createIconToggleButton(AwesomeIcon.DASHBOARD, "Domain", "10em", ContentDisplay.TOP);
        ToggleButton configurationButtonBig = AwesomeDude.createIconToggleButton(AwesomeIcon.GEARS, "Config", "10em", ContentDisplay.TOP);
        ToggleButton settingsButtonBig = AwesomeDude.createIconToggleButton(AwesomeIcon.FILE_TEXT, "Settings", "10em", ContentDisplay.TOP);
        ToggleButton updateButtonBig = AwesomeDude.createIconToggleButton(AwesomeIcon.DOWNLOAD, "Update", "10em", ContentDisplay.TOP);
        ToggleButton aboutButtonBig = AwesomeDude.createIconToggleButton(AwesomeIcon.INFO_SIGN, "About", "10em", ContentDisplay.TOP);

        SegmentedButton segmentedButtonBig = new SegmentedButton(serverButtonBig, configurationButtonBig, settingsButtonBig, updateButtonBig, aboutButtonBig);
        VBox root = new VBox();
        root.getChildren().addAll(githubLabel, ambulanceLabel, starButton, cloudButton, toggleButton, segmentedButton, segmentedButtonBig);

        Scene scene = new Scene(root, 500, 500);
        scene.getStylesheets().addAll(AwesomeStyle.BLUE.getStylePath());

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

    }

    public static void main(String[] args) {
        launch(args);
    }
}

With added stylesheet:

FontAwesome2

Without any additional styles:

FontAwesome1

Source can be found here:
FontAwesomeFX
FontAwesomeFX-Demo

Maven artifact:

<dependency>
    <groupId>de.jensd</groupId>
    <artifactId>fontawesomefx</artifactId>
    <version>8.0.0</version>
</dependency>

See also:
Griffon Plugin – fontawesome-javafx by Andres Almiray
Font Awesome usage with Swing (yes, Swing is still alive 😉 ) by Mario Torre