I want to use font font awesome in my project but I have no idea how to use font awesome in my project.
I had found some example but they can't be use in fxml.
I need help how to use it in my project using fxml
Thank you.
I want to use font font awesome in my project but I have no idea how to use font awesome in my project.
I had found some example but they can't be use in fxml.
I need help how to use it in my project using fxml
Thank you.
I think this is what you need ControlFX that include font awesome support. see the javadoc for more info (But I tested it one day and it works fine)
You can use fontawesomefx library by using .jar file in Scene Builder and you can browse all available icons with Fontawesome-fx Glyph browser
I ported the Android-Iconics library, developed by Mike Penz, to FX. Updates will follow soon (docs, as well)..
The showcase.jar will give you an overview of the icons.
Usage (Java 1.8 required):
(or see DialogPlayGround.java)
FxIconics on GitHub
As said by @Sedrick you can use fontawesomefx library and use it in FXML as follows:
Note: JavaFX 8 and FontAwesomeFx v8.9
dashboard.fxml
In scene builder looks like below:
If you use
SceneBuilder
try this.SceneBuilder
usingSceneBuilder
's Jar/FXML Manager.FontAwesomeIconView
,GlyphCheckBox
,MaterialDesignIconView
,MaterialIconView
, orWeatherIconView
Sample FXML:
Don't forget to add these jars to your project's classpath!
I achieved using FA Icons by adapting Jens Deters's approach.
His routines target dynamic gui composition opposing fxml's declarative way. Nevertheless, his AwesomeIcon enumeration (which maps FA comprehensible names with unicode characters) suited perfectly to my intents.
It should start by statically load the font in main/app class:
One can not use unicode characters in fxml (as needed to specify FA Icons), but can dynamic set attributes with such values. Hence having the above mentioned enumeration (AwesomeIcon), the job was done:
The import:
The node:
I end up implementing an Icon Widget/Control/Component for resuming the amount of code with two properties:
-fx-font-size
on label.New code (same effect):
The code for that control can be found here. You can also find an working example as it includes the font and testing code.