3

According to this Link javaFX 8u45 spinner, can be styled in numerous ways via style class. I do know how to do it by code.

For example:

spinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);

or,

spinner.getStyleClass().add("split-arrows-horizontal");

However, not by fxml. I did try this, but it did not work. I did this via scenebuilder, version 8.

<Spinner fx:id="spn" editable="true" styleClass="split-arrows-horizontal"/>
Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
jyonkheel
  • 443
  • 4
  • 17

1 Answers1

1

I am not sure why but defining styleClass in FXML like

<Spinner fx:id="spn" styleClass="split-arrows-horizontal"/>

will not result adding that style to styleClass list. You can check it by

@FXML private Spinner spn;

@Override
public void initialize( URL url, ResourceBundle rb )
{
    System.out.println( "getStyleClass: " + spn.getStyleClass() );
}

However, defining it in FXML as

<Spinner fx:id="spn">
     <styleClass>
        <String fx:value="split-arrows-horizontal" />
     </styleClass>
</Spinner>

works as expected.

Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
  • Works like charm, works great on scene builder 8, on the negative side this cant be done from scene builder it self, i had to write it from text editor – jyonkheel Jun 01 '15 at 05:17
  • Ok i got it to work from scene builder 8 itself, i added two style classes ("split-arrows-horizontal" and a dummy style class that doesnt change anything), and it worked, a discovery here is that these pre defined java fx style classes will not work in fxml unless it is with another legit or non existing style class – jyonkheel Jun 01 '15 at 05:35
  • Glad to hear that @jyonkheel. I almost never used scene builder so can't tell smthng about it. – Uluk Biy Jun 01 '15 at 05:44