Now I want to add functionality for adding a new row with the press of 'N'. So when pressing 'N' I add a new Object to my data list and try to get into editing mode the same way I do it when pressing 'E', but it won't work.
The new row gets created but I won't get the edit text field. That's why I tried to focus and select the newly created cell. The focus and selection work, but I won't get an edit field.
data.add(new Task("", "0")); table.edit(data.size() - 1, tableColumns.get(0));
It may have something to do with the fact that the new row just got inserted... I don't know :/
int lastRow = data.size() - 1; data.add(new Task("", "0")); table.getFocusModel().focus(lastRow); table.getSelectionModel().select(lastRow, tableColumns.get(0)); table.edit(lastRow, tableColumns.get(0));