Using Icon class in FXML requires the style attribute to be set

Issue #8 closed
mhana created an issue

Using the de.jensde.fx.fontawesome.Icon class in FXML requires that the style attribute be explicitly set. The class should be checking for a null value in it's constructor.

To reproduce, use the following FXML:

<Button text="Settings">
  <graphic>
    <Icon awesomeIcon="GEAR" />
  </graphic>
</Button>

This results in the Icon class setting the style to:

-fx-font-family: FontAwesome; -fx-font-size: 2em; null

Which causes a parsing error, because it does not check to see if the style argument is null or empty.

The workaround is to explicitly set style, size and styleClass attributes.

In addition, the Icon class needs additional constructors to handle all combinations for specifying the attributes in FXML. Currently it does not handle just specifying the following in attributes in FXML:

  • awesomeIcon, style
<Icon awesomeIcon="GEAR" style="-fx-font-size: 1em;" />
  • awesomeIcon, styleClass
<Icon awesomeIcon="GEAR" styleClass="myStyle"/>
  • awesomeIcon, style, styleClass
<Icon awesomeIcon="GEAR"  style="-fx-font-size: 1em;" styleClass="myClass" />

Using any of the above combinations causes the Icon class to use null for style and/or styleClass.

Comments (6)

  1. Log in to comment