- java.lang.Object
-
- org.controlsfx.glyphfont.GlyphFont
-
- org.controlsfx.glyphfont.FontAwesome
-
public class FontAwesome extends GlyphFont
Defines aGlyphFont
for the FontAwesome font set (see the FontAwesome website for more details).To use FontAwesome (or indeed any glyph font) in your JavaFX application, you firstly have to get access to the FontAwesome glyph font. You do this by doing the following:
GlyphFont fontAwesome = GlyphFontRegistry.font("FontAwesome");
This code works because all glyph fonts are found dynamically at runtime by the
GlyphFontRegistry
class, so you can simply request the font set you want from there.Once the font set has been loaded, you can simply start creating
FontAwesome.Glyph
nodes and place them in your user interface. For example:new Button("", fontAwesome.create(\uf013).fontColor(Color.RED));
Of course, this requires you to know that
\uf013
maps to a 'gear' icon, which is not always intuitive (especially when you re-read the code in the future). A simpler approach is to do the following:new Button("", fontAwesome.create(FontAwesome.Glyph.GEAR));
ornew Button("", fontAwesome.create("GEAR"));
It is possible to achieve the same result without creating a reference to icon font by simply usingGlyph
constructornew Button("", new Glyph("FontAwesome","GEAR");
You can use the above Glyph class also in FXML and set the fontFamily and icon property there.- See Also:
GlyphFont
,GlyphFontRegistry
,FontAwesome.Glyph
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FontAwesome.Glyph
The individual glyphs offered by the FontAwesome font.
-
Constructor Summary
Constructors Constructor Description FontAwesome()
Do not call this constructor directly - instead access theFontAwesome.Glyph
public static enumeration method to create the glyph nodes), or use theGlyphFontRegistry
class to get access.FontAwesome(InputStream is)
Creates a new FontAwesome instance which uses the provided font source.FontAwesome(String url)
Creates a new FontAwesome instance which uses the provided font source.
-
Method Summary
-
Methods inherited from class org.controlsfx.glyphfont.GlyphFont
create, create, create, getCharacter, getDefaultSize, getName, register, registerAll
-
-
-
-
Constructor Detail
-
FontAwesome
public FontAwesome()
Do not call this constructor directly - instead access theFontAwesome.Glyph
public static enumeration method to create the glyph nodes), or use theGlyphFontRegistry
class to get access. Note: Do not remove this public constructor since it is used by the service loader!
-
FontAwesome
public FontAwesome(String url)
Creates a new FontAwesome instance which uses the provided font source.- Parameters:
url
-
-
FontAwesome
public FontAwesome(InputStream is)
Creates a new FontAwesome instance which uses the provided font source.- Parameters:
is
-
-
-