boolean (KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { myTree.dispatchEvent(e); return true; } if (e.getKeyCode() == KeyEvent.VK_ESCAPE && getText().isEmpty()) { UIUtil.requestFocus(myTree); return true; } return false; }