cdox.util
Class EscapeListener

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended bycdox.util.EscapeListener
All Implemented Interfaces:
javax.swing.Action, java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, java.io.Serializable

public class EscapeListener
extends javax.swing.AbstractAction

This class simply clicks the button if the escape key is hit. This is useful for dialogs where the escape key should do the same as clicking the cancel button. A simple usage example would be: new EscapeListener(button,getRootPane());, where button would be the cancel button and the line would be placed in the constructor of a JDialog, for example.

Version:
May 22nd 2002
Author:
Rutger Bezema, Andreas Schmitz
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
EscapeListener(javax.swing.AbstractButton button, javax.swing.JRootPane panel)
          Constructs one.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Clicks the button.
 void invalidateListener()
          Unregisters the keystroke binding from the input and action map.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EscapeListener

public EscapeListener(javax.swing.AbstractButton button,
                      javax.swing.JRootPane panel)
Constructs one.

Parameters:
button - the button that should be pressed when the escape key is typed.
panel - where to register the key stroke.
Method Detail

invalidateListener

public void invalidateListener()
Unregisters the keystroke binding from the input and action map.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Clicks the button.

Parameters:
evt - an ActionEvent value.