org.xnap.commons.gui.shortcut
Class ActionShortcut

java.lang.Object
  extended by org.xnap.commons.gui.shortcut.AbstractShortcut
      extended by org.xnap.commons.gui.shortcut.ActionShortcut
All Implemented Interfaces:
Shortcut

public class ActionShortcut
extends AbstractShortcut

Provides an action based shortcut.

The action has to provide several values to make use of the shortcut.

It must provide the following values:

Action.ACTION_COMMAND_KEY, the preferences key

It should provide values for the following keys:

 


Field Summary
 
Fields inherited from interface org.xnap.commons.gui.shortcut.Shortcut
CATEGORY, DESCRIPTION, KEYSTROKE
 
Constructor Summary
ActionShortcut(Action action)
           
ActionShortcut(Action action, JComponent c)
           
 
Method Summary
 void addComponent(JComponent c, Action a)
          Installs the action into the action map of the component and sets up the shortcut mapping.
 Action getAction()
           
 JMenuItem getMenuItem()
           
 int getNumberOfComponents()
          Returns the number of components this shortcut is registered upon.
 void removeComponent(JComponent c)
          Removes the action mapping from the given component and removes it from its list of components.
 void setKeyStroke(KeyStroke stroke)
           
 void setMenuItem(JMenuItem menuItem)
           
 
Methods inherited from class org.xnap.commons.gui.shortcut.AbstractShortcut
addPropertyChangeListener, firePropertChange, getKeyStroke, getValue, putValue, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionShortcut

public ActionShortcut(Action action,
                      JComponent c)

ActionShortcut

public ActionShortcut(Action action)
Method Detail

addComponent

public void addComponent(JComponent c,
                         Action a)
Installs the action into the action map of the component and sets up the shortcut mapping.


getMenuItem

public JMenuItem getMenuItem()

getAction

public Action getAction()

setMenuItem

public void setMenuItem(JMenuItem menuItem)

removeComponent

public void removeComponent(JComponent c)
Removes the action mapping from the given component and removes it from its list of components.

Parameters:
c - the component this shortcuts is registered on

getNumberOfComponents

public int getNumberOfComponents()
Returns the number of components this shortcut is registered upon.


setKeyStroke

public void setKeyStroke(KeyStroke stroke)
Specified by:
setKeyStroke in interface Shortcut
Overrides:
setKeyStroke in class AbstractShortcut


Copyright © 2004-2007 XNap Commons Team. All Rights Reserved.