I intend to commit the changes on a TableCell upon clicking somewhere else on the TableView. Here is my implementation of createTextField method from the Oracle tutorial.
private void createTextField() {
textField.setText(getString());
textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
textField.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent t) -> {
if (t.getCode() == KeyCode.ENTER || t.getCode() == KeyCode.TAB) {
commitEdit(textField.getText());
} else if (t.getCode() == KeyCode.ESCAPE) {
cancelEdit();
}
});
textField.focusedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean t0, Boolean t1) -> {
if(!t1)
commitEdit(textField.getText());
});
}
The updated string doesnot reflect when i click on some other tablecell. I am using Java 8b123.