To allow editing of the cell contents, we need to provide two more things, CellFactory and onEditCommit logic:
// chapter10/table/EditableTableViewDemo.java// TextField based editable cellcolumnTitle.setCellFactory(TextFieldTableCell.forTableColumn());// logic which happes once editing is finishedcolumnTitle.setOnEditCommit((CellEditEvent<Chapter, String> t) -> { // setting new value for the title t.getRowValue().setTitle(t.getNewValue());});table.setEditable(true);
Now, you can double-click on the title cell, enter the new title, and it will be instantly applied to the data model: