protected JRootPane createRootPane(){ Action exitAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { dispose(); } }; JRootPane rootPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "exit"); rootPane.getActionMap().put("exit", exitAction); //rootPane.registerKeyboardAction(exitListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane;}