From ca16d56844999853ab2ab8a1ad8839cd7e7dd089 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 24 May 2007 08:24:11 +0000 Subject: [PATCH] dispose on escape --- tools/cooja/java/se/sics/cooja/GUI.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/GUI.java b/tools/cooja/java/se/sics/cooja/GUI.java index 667702b81..80231a477 100644 --- a/tools/cooja/java/se/sics/cooja/GUI.java +++ b/tools/cooja/java/se/sics/cooja/GUI.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: GUI.java,v 1.50 2007/05/23 09:10:15 fros4943 Exp $ + * $Id: GUI.java,v 1.51 2007/05/24 08:24:11 fros4943 Exp $ */ package se.sics.cooja; @@ -3209,7 +3209,7 @@ public class GUI { buttonBox.add(retryButton); } - JButton closeButton = new JButton("Close"); + final JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { errorDialog.dispose(); @@ -3217,6 +3217,16 @@ public class GUI { }); buttonBox.add(closeButton); + // Dispose on escape key + InputMap inputMap = errorDialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), "dispose"); + AbstractAction cancelAction = new AbstractAction(){ + public void actionPerformed(ActionEvent e) { + closeButton.doClick(); + } + }; + errorDialog.getRootPane().getActionMap().put("dispose", cancelAction); + errorPanel.add(messageBox); errorPanel.add(Box.createVerticalStrut(20)); errorPanel.add(buttonBox);