I have an application on JavaFX. In this application, I need to implement, the editor of the column. In the old version of the code worked perfectly:
myColumn.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<MyRowDataObject, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<MyRowDataObject, String> t) {
((MyRowDataObject) t.getTableView().getItems().get(
t.getTablePosition().getRow())
).setFirstName(t.getNewValue());
}
}
);
but when I tried to rewrite the code using the lambda
myColumn.setOnEditCommit((TableColumn.CellEditEvent event) ->
((MyRowDataObject) event.getTableView().getItems().get(event.getTablePosition().getRow())).setEmail(event.getNewValue().toString())
);
I get an error :Error: java: incompatible types: incompatible parameter types in lambda expression Tell me how to specify the type of a lambda expression?
Maybe someone will be interested, turned to compile the code as follows.
myColumn.setOnEditCommit(event -> {
final TableColumn.CellEditEvent _evn = (TableColumn.CellEditEvent) event;
((MyRowDataObject) _evn.getTableView().getItems().get(_evn.getTablePosition().getRow())).setEmail(_evn.getNewValue().toString());
});
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.