Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all, about textProperty().</p> <p>Look here to see : </p> <p><a href="http://docs.oracle.com/javafx/2/api/index.html" rel="nofollow">http://docs.oracle.com/javafx/2/api/index.html</a></p> <p>TextProperty() is a property of labeled parent class, you will learn nothing from it, because it is not used. It is tricky thing : cell - inheritant of labeled control. TextField, which you see, when start editing, it is a graphic node of cell (graphicProperty()) (as far as I remember documentation).</p> <p>And, this graphic node is assigned by a text field, only when editing starts.</p> <p>AFAIK, there is no direct access to editable node.</p> <p>The way to solve the issue - implement editable cell by your self.</p> <p>Let me talk to developer, to learn more...</p> <p>Supposing, you have DataItem class, which contains String, and supposing that TableView has encapsulated data type DataItem, and the only column has the same encapsulated data type, you may use this implementation as basis : </p> <pre><code> public class TextFieldTableCell extends TableCell&lt;DataItem, DataItem&gt; { private TextField textField; public TextFieldTableCell() { } @Override public void startEdit() { super.startEdit(); if (isEmpty()) { return; } if (textField == null) { createTextBox(); } else { textField.setText(new CellCustomStringConverter().toString(getItem())); } setGraphic(textField); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); textField.requestFocus(); textField.selectAll(); } @Override public void cancelEdit() { super.cancelEdit(); setContentDisplay(ContentDisplay.TEXT_ONLY); } @Override public void updateItem(DataItem item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { if (textField != null) { textField.setText(new CellCustomStringConverter().toString(item)); } setText(item.toString()); } } private void createTextBox() { textField = new TextField(new CellCustomStringConverter().toString(getItem())); textField.setId(TABLE_EDIT_ID); textField.setOnKeyReleased(new EventHandler&lt;KeyEvent&gt;() { @Override public void handle(KeyEvent t) { if (t.getCode() == KeyCode.ENTER) { commitEdit(new DataItem(textField.getText())); } else if (t.getCode() == KeyCode.ESCAPE) { cancelEdit(); } } }); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload