I am detecting the change of value of a group of buttons with Listener
. If there is nothing selected I put the previous value before the change, but this causes me to redial the Listener
How can I avoid it?
The code is:
toggleGroup.selectedToggleProperty().addListener(
(ObservableValue<? extends Toggle> arg0, Toggle oldValue, Toggle newValue) -> {
if (toggleGroup.getToggles().indexOf(toggleGroup.getSelectedToggle()) == -1) {
toggleGroup.selectToggle(oldValue); // esto provoca rellamada al Listener
}
}
);