AddAll items in comboBox

-1

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");
}
    
asked by anonymous 12.07.2017 / 15:30

1 answer

0

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) .

    
13.07.2017 / 17:02