只有当TableColumn<CustomObject, Boolean> tableColumnTwo
复选框被选中时,我才会根据CustomObject
中的字段值禁用TableColumn<CustomObject, String> tableColumn
。我可以禁用内部但不知道如何检查里面updateItem
复选框的状态的文本框下面是相关的代码片段,会非常感激,如果任何人都可以在这个JavaFX根据复选框状态禁用TableColumn
@FXML
private TableColumn<CustomObject, Boolean> tableColumnTwo;
@FXML
private TableColumn<CustomObject, String> tableColumn;
tableColumn.setCellFactory(
new Callback<TableColumn<CustomObject, String>, TableCell<CustomObject, String>>() {
@Override
public TableCell<CustomObject, String> call(TableColumn<CustomObject, String> paramTableColumn) {
return new TextFieldTableCell<CustomObject, String>(new DefaultStringConverter()) {
@Override
public void updateItem(String s, boolean empty) {
super.updateItem(s, empty);
TableRow<CustomObject> currentRow = getTableRow();
if(currentRow.getItem() != null && !empty) {
if (currentRow.getItem().getPetrified() == false) { // Need to check if checkbox is checked or not
setDisable(true);
setEditable(false);
this.setStyle("-fx-background-color: red");
} else {
setDisable(false);
setEditable(true);
setStyle("");
}
}
}
};
}
});
https://stackoverflow.com/help/how-to-ask或者换句话说:请提供一个可运行的示例,说明你在做什么以及如何达不到目标:) – kleopatra