From 8e9cd7d94da852dae801b0b67f82255281735495 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Sun, 24 Feb 2013 21:26:05 +0000 Subject: [PATCH] BudgetDialog: if ESC is pressed, close the dialog git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@584 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/gui/BudgetDialog.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/micropolisj/gui/BudgetDialog.java b/src/micropolisj/gui/BudgetDialog.java index 4be4697..389262e 100644 --- a/src/micropolisj/gui/BudgetDialog.java +++ b/src/micropolisj/gui/BudgetDialog.java @@ -196,6 +196,12 @@ public class BudgetDialog extends JDialog pack(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setLocationRelativeTo(owner); + getRootPane().registerKeyboardAction(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + dispose(); + }}, + KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), + JComponent.WHEN_IN_FOCUSED_WINDOW); } private void setAutoRequestFocus_compat(boolean v)