如何执行禁用表列中的复选框启用功能在JavaFX中,如果我选择了一个复选框,则需要禁用其余的复选框。
如果我选择一个复选框,则需要在JavaFx中禁用表视图中的其余复选框。。
colSelect.setCellFactory(new Callback<TableColumn<LogVoiceBroadCast, Boolean>, TableCell<LogVoiceBroadCast, Boolean>>()
{
@Override
public TableCell<LogVoiceBroadCast, Boolean> call(TableColumn<LogVoiceBroadCast, Boolean> param) {
final TableCell<LogVoiceBroadCast, Boolean> cell = new TableCell<LogVoiceBroadCast, Boolean>() {
@Override
public void updateItem(Boolean value, boolean empty) {
super.updateItem(value, empty);
if (!empty || value != null) {
CheckBox checkBox = new CheckBox();
checkBox.setSelected(false);
checkBox.addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
if (!checkBox.isSelected()) {
LogVoiceBroadCast item = (LogVoiceBroadCast) getTableRow().getItem();
voiceFiles.add(item);
} else {
LogVoiceBroadCast item = (LogVoiceBroadCast) getTableRow().getItem();
voiceFiles.remove(item);
}
}
});
final HBox hbox = new HBox(checkBox);
hbox.setAlignment(Pos.CENTER);
hbox.setSpacing(12);
setGraphic(hbox);
} else {
setGraphic(null);
}
}
};
cell.setAlignment(Pos.CENTER);
return cell;
}
});