Top Description Fields Constructors Methods
org.controlsfx.glyphfont

public Class Glyph

extends Label
implements Duplicatable<Glyph>
Class Inheritance
All Implemented Interfaces
org.controlsfx.tools.Duplicatable
Imports
java.util.Optional, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.collections.ObservableList, javafx.scene.Node, javafx.scene.control.Label, javafx.scene.paint.*, javafx.scene.text.Font, org.controlsfx.control.action.Action, org.controlsfx.tools.Duplicatable

Represents one glyph from the font. The glyph is actually a label showing one character from the specified font. It can be used as 'graphic' on any UI control or Action. It can also directly be used in FXML. Examples:
new Button("", new Glyph("FontAwesome", "BEER"))
new Button("", new Glyph("FontAwesome", FontAwesome.Glyph.BEER))
Thy Glyph-Class also offers a fluent API to customize the look of the Glyph. For example, you can set the color color(javafx.scene.paint.Color) or also add effects such as useHoverEffect()

An ability to retrieve glyph node by combination of font name and glyph name extends to the org.controlsfx.control.action.ActionProxy graphic attribute, where the "font>" prefix should be used. For more information see org.controlsfx.control.action.ActionProxy.

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_CSS_CLASS

* Private fields * *

private final ObjectProperty<Object>
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public
Glyph()

Empty Constructor (used by FXML)

public
Glyph(String
The family name of the font. Example: "FontAwesome"
fontFamily
,
char
The Unicode character of the glyph
unicode
)

Creates a new Glyph

public
Glyph(String
The family name of the font. Example: "FontAwesome"
fontFamily
,
Object
The icon - which can be the name (String) or Enum value. Example: FontAwesome.Glyph.BEER
icon
)

Creates a new Glyph

Method Summary

Modifier and TypeMethod and Description
public Glyph

Returns:

Returns this instance for fluent API
color
(Color color)

Sets the glyph color

public static Glyph

Returns:

A instance of a Glyph node
create
(String
The font and glyph separated by a pipe. Example: "FontAwesome|STAR"
fontAndGlyph
)

Retrieve glyph by font name and glyph name using one string where font name an glyph name are separated by pipe.

public Glyph
duplicate()

Implements org.controlsfx.tools.Duplicatable.duplicate.

Allows glyph duplication.

public Glyph

Returns:

Returns this instance for fluent API
fontFamily
(String
A font family name
fontFamily
)

Sets the glyph icon font family

public String
getFontFamily()

Gets the font family of this glyph

public double
getFontSize()

Gets the font size of this glyph

public Object
public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public ObjectProperty<Object>
iconProperty()

The icon name property.

public void
setColor(Color color)

Set the Color of this Glyph

public void
setFontFamily(String family)

Sets the font family of this glyph Font size is reset to default glyph font size

public void
setFontSize(double size)

Sets the font size of this glyph

public void
setIcon(Object
This can either be the Glyph-Name, Glyph-Enum Value or a unicode character representing the sign.
iconValue
)

Set the icon to display.

private void
setTextUnicode(char unicode)

Sets the given char as text

public Glyph

Returns:

Returns this instance for fluent API
size
(double size)

Sets glyph size

public Glyph

Returns:

Returns this instance for fluent API
sizeFactor
(int factor)

Sets glyph size using size factor based on default font size

private void
updateIcon()

This updates the text with the correct unicode value so that the desired icon is displayed.

public Glyph

Returns:

Returns this instance for fluent API
useGradientEffect
()

Adds the gradient effect style

public Glyph

Returns:

Returns this instance for fluent API
useHoverEffect
()

Adds the hover effect style

Inherited from javafx.scene.control.Label:
createDefaultSkingetInitialFocusTraversablegetLabelForlabelForPropertysetLabelFor

Field Detail

DEFAULT_CSS_CLASSback to summary
public static final String DEFAULT_CSS_CLASS

* Private fields * *

iconback to summary
private final ObjectProperty<Object> icon
STYLE_GRADIENTback to summary
public static final String STYLE_GRADIENT
STYLE_HOVER_EFFECTback to summary
public static final String STYLE_HOVER_EFFECT

Constructor Detail

Glyphback to summary
public Glyph()

Empty Constructor (used by FXML)

Glyphback to summary
public Glyph(String fontFamily, char unicode)

Creates a new Glyph

Parameters
fontFamily:String

The family name of the font. Example: "FontAwesome"

unicode:char

The Unicode character of the glyph

Glyphback to summary
public Glyph(String fontFamily, Object icon)

Creates a new Glyph

Parameters
fontFamily:String

The family name of the font. Example: "FontAwesome"

icon:Object

The icon - which can be the name (String) or Enum value. Example: FontAwesome.Glyph.BEER

Method Detail

colorback to summary
public Glyph color(Color color)

Sets the glyph color

Returns:Glyph

Returns this instance for fluent API

createback to summary
public static Glyph create(String fontAndGlyph)

Retrieve glyph by font name and glyph name using one string where font name an glyph name are separated by pipe.

Parameters
fontAndGlyph:String

The font and glyph separated by a pipe. Example: "FontAwesome|STAR"

Returns:Glyph

A instance of a Glyph node

duplicateback to summary
public Glyph duplicate()

Implements org.controlsfx.tools.Duplicatable.duplicate.

Allows glyph duplication. Since in the JavaFX scenegraph it is not possible to insert the same Node in multiple locations at the same time, this method allows for glyph reuse in several places

Annotations
@Override
fontFamilyback to summary
public Glyph fontFamily(String fontFamily)

Sets the glyph icon font family

Parameters
fontFamily:String

A font family name

Returns:Glyph

Returns this instance for fluent API

getFontFamilyback to summary
public String getFontFamily()

Gets the font family of this glyph

getFontSizeback to summary
public double getFontSize()

Gets the font size of this glyph

getIconback to summary
public Object getIcon()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
iconPropertyback to summary
public ObjectProperty<Object> iconProperty()

The icon name property. This must either be a Glyph-Name (either string or enum value) known by the GlyphFontRegistry. Alternatively, you can directly submit a unicode character here.

setColorback to summary
public void setColor(Color color)

Set the Color of this Glyph

setFontFamilyback to summary
public void setFontFamily(String family)

Sets the font family of this glyph Font size is reset to default glyph font size

setFontSizeback to summary
public void setFontSize(double size)

Sets the font size of this glyph

setIconback to summary
public void setIcon(Object iconValue)

Set the icon to display.

Parameters
iconValue:Object

This can either be the Glyph-Name, Glyph-Enum Value or a unicode character representing the sign.

setTextUnicodeback to summary
private void setTextUnicode(char unicode)

Sets the given char as text

sizeback to summary
public Glyph size(double size)

Sets glyph size

Returns:Glyph

Returns this instance for fluent API

sizeFactorback to summary
public Glyph sizeFactor(int factor)

Sets glyph size using size factor based on default font size

Returns:Glyph

Returns this instance for fluent API

updateIconback to summary
private void updateIcon()

This updates the text with the correct unicode value so that the desired icon is displayed.

useGradientEffectback to summary
public Glyph useGradientEffect()

Adds the gradient effect style

Returns:Glyph

Returns this instance for fluent API

useHoverEffectback to summary
public Glyph useHoverEffect()

Adds the hover effect style

Returns:Glyph

Returns this instance for fluent API