I have a table cell factory responsible for creating an editable cell in a JavaFX TableView.
I\'m trying to implement some added functionality to the tableview so th
You could do it by overriding the method commitEdit as next:
@Override
public void commitEdit(T item) {
// This block is necessary to support commit on losing focus, because
// the baked-in mechanism sets our editing state to false before we can
// intercept the loss of focus. The default commitEdit(...) method
// simply bails if we are not editing...
if (!isEditing() && !item.equals(getItem())) {
TableView table = getTableView();
if (table != null) {
TableColumn column = getTableColumn();
CellEditEvent event = new CellEditEvent<>(
table, new TablePosition(table, getIndex(), column),
TableColumn.editCommitEvent(), item
);
Event.fireEvent(column, event);
}
}
super.commitEdit(item);
}
This workaround comes from https://gist.github.com/james-d/be5bbd6255a4640a5357#file-editcell-java-L109