void (KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { if (table.isEditing()) { e.consume(); table.removeEditor(); if (e.getSource() != table) { ((JComponent)e.getSource()).removeKeyListener(this); } } } }