简体   繁体   中英

How to properly make JavaFX TableView editable in Java 8?

I want the user to be able to edit a cell containing a String in a Java TableView. In my controller I have simple:

// At beginning of class declaration
@FXML private TableColumn<FormTokens, String> valuColumn;

// Later at initialization
valuColumn.setCellFactory(TextFieldTableCell.forTableColumn());

When attempting to do the following:

valuColumn.setCellValueFactory(TextFieldTableCell.<FormTokens>forTableColumn());

I am getting a:

Error:(409, 95) java: incompatible types: javafx.util.Callback<javafx.scene.control.TableColumn<sample.FormTokens,java.lang.String>,javafx.scene.control.TableCell<sample.FormTokens,java.lang.String>> cannot be converted to javafx.util.Callback<javafx.scene.control.TableColumn.CellDataFeatures<sample.FormTokens,java.lang.String>,javafx.beans.value.ObservableValue<java.lang.String>>

What is the proper way to make it such that a user can click/double click on a cell and modify the contents?

您确定要调用setCellFactory(...)而不是setCellValueFactory(...)吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM