com.isti.util.gui
Class KeyEventsRedirector
java.lang.Object
javax.swing.AbstractAction
com.isti.util.gui.KeyEventsRedirector
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
public class KeyEventsRedirector
- extends javax.swing.AbstractAction
Class KeyEventsRedirector redirects keyboard events to a specified
component. This class is useful for situations where a given
component always wants to process certain keystrokes, regardless
of whether or not the component has the current input focus.
To intercept keystrokes, accelerators are defined on menu items
held in an invisible menu that is added to a displayed menu bar.
If a component (such as the target component or a displayed menu)
processes a given keystroke then it will not be received by this
redirector.
- See Also:
- Serialized Form
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary |
KeyEventsRedirector(javax.swing.JMenuBar menuBarObj,
java.awt.Component targetComponent,
javax.swing.KeyStroke[] keyStrokesArr)
Creates and installs a redirector object. |
Method Summary |
void |
actionPerformed(java.awt.event.ActionEvent evtObj)
Action-performed method for all menu item accelerators used by this
object. |
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 |
KeyEventsRedirector
public KeyEventsRedirector(javax.swing.JMenuBar menuBarObj,
java.awt.Component targetComponent,
javax.swing.KeyStroke[] keyStrokesArr)
- Creates and installs a redirector object.
- Parameters:
menuBarObj
- a displayed menu bar.targetComponent
- the target component to sent key events to.keyStrokesArr
- an array of 'keyStroke' objects defining which
keys are to be redirected.
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent evtObj)
- Action-performed method for all menu item accelerators used by this
object.
- Parameters:
evtObj
- the event object for the event.