RadioButton&CheckBox
RadioButton
RadioButton rb1 = new RadioButton("rb1");
RadioButton rb2 = new RadioButton("rb2");
RadioButton rb3 = new RadioButton("rb3");
RadioButton rb4 = new RadioButton("rb4");
ToggleGroup toggleGroup = new ToggleGroup();
toggleGroup.getToggles().addAll(rb1, rb2, rb3, rb4);
rb2.setSelected(true);
toggleGroup.selectToggle(rb3);
rb1.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
}
});
toggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
@Override
public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
}
});
ObservableList<Node> children = root.getChildren();
children.addAll(rb1, rb2, rb3, rb4);
CheckBox
CheckBox cb1 = new CheckBox("cb1");
CheckBox cb2 = new CheckBox("cb2");
CheckBox cb3 = new CheckBox("cb3");
CheckBox cb4 = new CheckBox("cb4");
cb2.setSelected(true);
cb3.setIndeterminate(true);
cb3.setAllowIndeterminate(true);
cb1.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
}
});
ObservableList<Node> children = root.getChildren();
children.addAll(cb1, cb2, cb3, cb4);