boolean (KeyStroke ks, KeyEvent e, int condition, boolean pressed) { //Mnemonics and actions if (e.isAltDown() || e.isMetaDown() || e.isControlDown()) { return false; } if (e.getKeyCode() == VK_ESCAPE && pressed) { final int row = getSelectedRow(); if (row != -1 && isRowEmpty(row)) { MyTableModel model = getModel(); final int count = model.getRowCount(); model.removeRow(row); int newRow = count == row + 1 ? row - 1 : row; if (0 <= newRow && newRow < model.getRowCount()) { setRowSelectionInterval(newRow, newRow); } } } if (e.getKeyCode() == VK_ENTER) { if (e.getID() == KEY_PRESSED) { if (!isEditing() && e.getModifiers() == 0) { editCellAt(getSelectedRow(), getSelectedColumn()); } else if (isEditing()) { TableUtil.stopEditing(this); if (e.isControlDown() || e.isMetaDown()) { return false; } else { final int row = getSelectedRow() + 1; if (row < getRowCount()) { getSelectionModel().setSelectionInterval(row, row); } } } else { if (e.isControlDown() || e.isMetaDown()) { return false; } } } e.consume(); return true; } if (isEditing() && e.getKeyCode() == VK_TAB) { if (pressed) { final KeyboardFocusManager mgr = KeyboardFocusManager.getCurrentKeyboardFocusManager(); if (e.isShiftDown()) { mgr.focusPreviousComponent(); } else { mgr.focusNextComponent(); } } return true; } final boolean isUp = e.getKeyCode() == VK_UP; final boolean isDown = e.getKeyCode() == VK_DOWN; if (isEditing() && (isUp || isDown) && e.getModifiers() == 0 && e.getID() == KEY_PRESSED) { int row = getSelectedRow(); super.processKeyBinding(ks, e, condition, pressed); if (!isEditing() && row != getSelectedRow()) { TableUtil.editCellAt(this, getSelectedRow(), 0); e.consume(); return true; } } return super.processKeyBinding(ks, e, condition, pressed); }