我希望仅在选中复选框时才TableColumn<CustomObject, String> tableColumn
基于字段值禁用 a。我可以禁用里面的文本框但是不确定如何检查里面的复选框的状态
下面是相关的代码片段,如果有人能阐明这一点,我将不胜感激CustomObject
TableColumn<CustomObject, Boolean> tableColumnTwo
public void updateItem(String s, boolean empty)
updateItem
@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("");
}
}
}
};
}
});