void () { wrapAction("TAB", table -> { if (table.getRowCount() == 0 || table.getSelectionModel().getLeadSelectionIndex() == table.getRowCount() - 1 && table.getColumnModel().getSelectionModel().getLeadSelectionIndex() == table.getColumnCount() - 1) { KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(); return true; } return false; }); wrapAction("shift TAB", table -> { if (table.getRowCount() == 0 || table.getSelectionModel().getLeadSelectionIndex() == 0 && table.getColumnModel().getSelectionModel().getLeadSelectionIndex() == 0) { KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(); return true; } return false; }); }