[JAVA] How to close a JFrame with Escape(ESC)?
// on ESC key close frame getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel"); getRootPane().getActionMap().put("Cancel", new AbstractAction(){ public void actionPerformed(ActionEvent e) { dispose(); } }); // on close window the close method is called setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowLis..
2015. 3. 6. 11:05