I created a ChoiceBox, where at each level selected, a method should be called; but the following happens, any selected item calls the method; how to make a condition, that is, depending on the item selected, calls a certain method. It follows a part of the code.
ChoiceBox cb = new ChoiceBox();
cb.setId("btn_transparent_cb");
cb.getItems().addAll("Nível 1", "Nível 2", "Nível 3", "Nível 4");
//cb.getSelectionModel().selectFirst();
cb.getSelectionModel().selectedIndexProperty()
.addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue ov, Number value, Number new_value) {
exemploMetodo();
}
});