Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javafx TableView goes out of focus after cell edit

A starter in javafx, I need some help. I followed the example here and got the cell edit working perfectly. I enabled the cell selection of the TableViewsetCellSelectionEnabled true in TableViewSelectionModel. But when I finish editing the cell, the TableView loses focus and the focus goes to the first node in the scene. I tried getting the currently selected cell and use focus() of getFocusModel() even in a Platform.runLater but no result.

like image 849
Ninad Pardhiye Avatar asked Nov 05 '14 21:11

Ninad Pardhiye


1 Answers

A workaround could be to request the focus on the setEditOnCommit:

    firstNameCol.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<Person, String>>() {
        @Override
        public void handle(TableColumn.CellEditEvent<Person, String> event) {
            table.requestFocus();
        }
    });
like image 102
Rascarcapac Avatar answered Oct 22 '22 11:10

Rascarcapac