Javafx TableView goes out of focus after cell edit
Asked Answered
C

1

6

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.

Cimah answered 5/11, 2014 at 21:44 Comment(1)
I have the same problem. Anyone found a solution?Conde
C
4

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();
        }
    });
Conde answered 5/12, 2016 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.