I have a treetable column, to which I am adding checkbox as below
isPrimary.setCellFactory( new Callback, TreeTableCell>() { @Override public TreeTableCell call(TreeTableColumn param) { return new LiveCheckBoxTreeTableCell(); } });
I am writing my own checkbox as below
public class LiveCheckBoxTreeTableCell extends TreeTableCell{ private final CheckBox checkBox = new CheckBox(); private ObservableList selectedCheckBoxes = FXCollections.observableArrayList(); private ObservableList unselectedCheckBoxes = FXCollections.observableArrayList();
@Override
public void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
} else{
setGraphic(checkBox);
if (checkBox.isSelected()) {
selectedCheckBoxes.add(checkBox);
} else {
unselectedCheckBoxes.add(checkBox);
}
checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2) {
if (aBoolean2) {
unselectedCheckBoxes.remove(checkBox);
selectedCheckBoxes.add(checkBox);
} else {
selectedCheckBoxes.remove(checkBox);
unselectedCheckBoxes.add(checkBox);
}
}
});
}
}
}
When I check one checkbox other checkbox in the isPrimary column should be disabled. But the Checkbox I check and uncheck will get disabled.Others will remain enabled. Any Javafx please help me to disable unchecked checkbox and enable all checkbox when I uncheck any checked checkbox.
Aucun commentaire:
Enregistrer un commentaire