Replace the ChoiceBox elements in JavaFx?

0

to add elements to a ChoiceBox , in JavaFx , we use add () methods or addAll () . Now if I have a ChoiceBox with a series of elements, how did he replace them with others? Is there a direct method other than cleaning the content and adding a new one?

// create the choice box with some items
ChoiceBox cb = new ChoiceBox(
    FXCollections.observableArrayList("uno", "dos"));

// clean ChoiceBox items
cb.getItems().clear();

// add new ChoiceBox items
cb.getItems().addAll(
    FXCollections.observableArrayList("nuevo", "otro", "xxx"));
    
asked by Orici 10.06.2018 в 19:17
source

0 answers