KeyAdapter (final int rowIndex, final int vColIndex) { return new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { doOKAction(rowIndex, vColIndex); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { cancelEditing(); } } }; }