]> gitweb.fperrin.net Git - GpsPrune.git/blob - src/tim/prune/gui/DialogCloser.java
Moved source into separate src directory due to popular request
[GpsPrune.git] / src / tim / prune / gui / DialogCloser.java
1 package tim.prune.gui;
2
3 import java.awt.event.KeyAdapter;
4 import java.awt.event.KeyEvent;
5
6 import javax.swing.JDialog;
7
8 /**
9  * Convenience class to close a dialog when the escape key is pressed
10  */
11 public class DialogCloser extends KeyAdapter
12 {
13         /** dialog to close */
14         private JDialog _dialog = null;
15
16         /**
17          * Constructor
18          * @param inDialog dialog to close
19          */
20         public DialogCloser(JDialog inDialog) {
21                 _dialog = inDialog;
22         }
23
24         /**
25          * React to the release of the escape key
26          */
27         public void keyReleased(KeyEvent e)
28         {
29                 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
30                         _dialog.dispose();
31                 }
32         }
33 }