In the official documentation of JavaFX on edit data a table view, there is example only for String, in my program I have two INTEGER columns, to edit them I use : select the row, click button, new form shows up, after the user fill it, hit ok, then data changes. Now I want to move from this to direct input in the table. How can I do this with Integer Columns.
TreeTableColumn<RootMaster, Integer> dataColumn = new TreeTableColumn<>(rs.getString("tab.budget.table.column.budgeted"));
dataColumn.setEditable(true);
dataColumn.setCellValueFactory(new TreeItemPropertyValueFactory<RootMaster, Integer>("budgetSum"));
dataColumn.setCellFactory(col -> {
TreeTableCell<RootMaster, Integer> cell = new TreeTableCell<RootMaster, Integer>() {
@Override
public void updateItem(Integer item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
setText(item.toString());
}
}
};
cell.setAlignment(Pos.CENTER);
return cell;
});
Thanks
You can do
dataColumn.setCellFactory(
TextFieldTreeTableCell.forTreeTableColumn(new IntegerStringConverter()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With