Yousef Ahmed Yousef Ahmed - 4 months ago 55
Java Question

JAVAFX ComboBox is blank

I am very new to programming and can't seem to get past this hiccup. I would like to have a choicebox that is populated with options and that is present immediately. I have tried defining the ObservableList and then creating a ComboBox but it is empty when I actually run the code. I do not need to edit this array after it appears. Here is my code:

ObservableList<String> options =
"Option 1",
"Option 2",
"Option 3"

final ComboBox stores = new ComboBox(options);

private Label label;

I have created the combobox in the FXML document using Scene Builder with FXid stores.

Any help would be appreciated!
Thanks in advance.


when you decorate your javafx component with anotation, you should not initiate it. Only this is ok;

 @FXML ComboBox stores;

in the initialize method in your controller class. add this code: