I have a ComboBox
, and I'm trying to put items (string values) but it is not accepting.
I did it this way:
private ComboBox<?> meuCombo;
public void combos() {
meuCombo.getItems().addAll("A", "B");
}
I have a ComboBox
, and I'm trying to put items (string values) but it is not accepting.
I did it this way:
private ComboBox<?> meuCombo;
public void combos() {
meuCombo.getItems().addAll("A", "B");
}
Notice that the getItems()
method of the comboBox returns an ObservableList . Why do not you try manually setting the ObservableList of your ComboBox , like this:
private ComboBox<String> meuCombo;
public void combos(){
ObservableList<String> itens = FXCollections.observableArrayList();
itens.addAll("A", "B");
meuCombo.setItems(list)
}
I did not see in your code how you instantiated your ComboBox but you can pass the ObservableList as an argument like this: meuCombo = new ComboBox(itens)
.