isText.setEditable(true);
isText.setCellValueFactory(new Callback<CellDataFeatures<TableItem, Boolean>, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(CellDataFeatures<TableItem, Boolean> p) {
return new SimpleBooleanProperty(p.getValue().getIsText());
}
});
isText.setCellFactory(new Callback<TableColumn<TableItem, Boolean>, TableCell<TableItem, Boolean>>() {
@Override
public TableCell<TableItem, Boolean> call(TableColumn<TableItem, Boolean> p) {
return new CheckBoxTableCell<>();
}
});
Вот мой код, я действительно хочу, чтобы проверить и снимите этот флажок и изменить исходные данные по методу I, определенной ниже,Как сделать мой CheckBoxTableCell доступным для редактирования в Javafx?
/**
* Set the boolean value of if this variable is viewed as text
*/
public void setIsText(boolean newVal) {
isText.set(newVal);
}
Это моя полная реализация TableItem
,
public class TableItem {
private final SimpleIntegerProperty index;
private final SimpleStringProperty variable;
private final SimpleBooleanProperty isText;
/**
* Constructor for TableItem
*
* @param index
* index of the variable
* @param variable
* variable name
* @param isText
* initial boolean value of if it is viewed as a text or not
*/
public TableItem (int index, String variable, boolean isText) {
this.index = new SimpleIntegerProperty(index);
this.variable = new SimpleStringProperty(variable);
this.isText = new SimpleBooleanProperty(isText);
}
/**
* Get the boolean value of if this variable is viewed as text
* @return
* the boolean value notifies if the variable is text or not
*/
public boolean getIsText() {
return isText.get();
}
/**
* Set the boolean value of if this variable is viewed as text
*/
public void setIsText(boolean newVal) {
isText.set(newVal);
}
/**
* Get the index of the variable
*
* @return
* the index
*/
public int getIndex() {
return index.get();
}
/**
* Get the string representation of the variable
*
* @return
* the string of the variable
*/
public String getVariable() {
return variable.get();
}
}
Так что же происходит, что это отличается от того, что вы хотите, чтобы это произошло? –
Столбец окна редактирования недоступен, нажав – xxx222
Вы сделали таблицу доступной для редактирования? –