+ * Add a key listener that closes the find dialog on 'Esc' key press
+ */
+ private void addKeyListener()
+ {
+ /*
+ * add the listener to the field with focus
+ */
+ textfield.addKeyListener(new KeyAdapter()
+ {
+ @Override
+ public void keyPressed(KeyEvent evt)
+ {
+ switch (evt.getKeyCode())
+ {
+ case 27:
+ // close this window on Esc key
+ Finder.this.setVisible(false);
+ try
+ {
+ Finder.this.frame.setClosed(true);
+ } catch (PropertyVetoException e)
+ {
+ // ignore
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ });
+ }
+
+ /**