How to make editable JavaFX TableView cells?

There are many tutorials and many suggestions for this, expanding JavaFX cells to make them editable. Good question about thread_stack .
But official tutorials use a method call to create a callback without writing all this code, calling

lastNameCol.setCellFactory(TextFieldTableCell.forTableColumn()); 

However, when I do this in my code (FormTokens is my "model"):

 // At beginning of class declaration @FXML private TableColumn<FormTokens, String> valuColumn; // Later at initialization valuColumn.setCellFactory(TextFieldTableCell.forTableColumn()); 

The compiler says:

SetCellFactory method ( Callback<TableColumn<FormTokens,String>,TableCell<FormTokens,String>>)
in type TableColumn<FormTokens,String>
not applicable for arguments (Callback<TableColumn<Object,String>,TableCell<Object,String>>)

If I delete the method call mentioned above, everything works fine, except that the TableView cells are not editable. What am I doing wrong?

edit: I just found this: Javafx TableView cannot be edited But there are no solutions. How to make Callback<TableColumn<Object,... on Callback<TableColumn<FormTokens,... ?

+8
javafx-2 tableview
source share
1 answer

Specify the exact type explicitly for the general parameter as

 valuColumn.setCellFactory(TextFieldTableCell.<FormTokens>forTableColumn()); 
+13
source share

All Articles