2

What is the FXML equivalent for this (cb is a ChoiceBox):

cb.getSelectionModel().select(1);

I tried something like this:

<ChoiceBox SelectionModel.select="1">
....
</ChoiceBox>

and

<ChoiceBox>
<SelectionModel select="1"/>
....
</ChoiceBox>

and a lot of similar variations, but those didn't work

Sergey Grinev
  • 34,078
  • 10
  • 128
  • 141
zorglub76
  • 4,852
  • 7
  • 37
  • 46

2 Answers2

0

if you using scene builder then try this in fxml.

<ChoiceBox fx:id="choice" layoutX="181.0" layoutY="14.0" prefHeight="25.0" prefWidth="119.0" value="item1" >
<String fx:value="item1" />
<Separator />
<String fx:value="item2" />
</ChoiceBox>
M.Onirban
  • 1
  • 1
0

Right now, you have to do it via Java code in the Controller class. There is a pending enhancement request already submitted to handle this in the FXML. It looks very similar to your posting here.

JimClarke
  • 1,409
  • 13
  • 12