I have issues with populating comboBox in JavaFX with values in a list. I am very green with UI development so nothing I found online was really helpful to me. Now I have a Class myClass
with a method getNames()
that returns List<String>
. Now I need the names form that method to be selectable from the dropdown menu. I tried something like this in my Controller :
ObservableList<String> options = FXCollections.observableArrayList(myClass.getNames());
@FXML
final ComboBox comboBox = new ComboBox(options);
but when I launch my program my comboBox is still empty. Of course I also put fx:id = "comboBox"
in .fxml file.
Did I miss something or should I do that with a completely different method?