Package de.sciss.gui
Class MenuAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- de.sciss.gui.MenuAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener,javax.swing.Action
- Direct Known Subclasses:
BasicMenuFactory.ActionOpenRecent,BasicMenuFactory.ActionPreferences,BasicMenuFactory.ActionShowWindow,PrefMenuAction,ShowWindowAction,URLViewerAction
public abstract class MenuAction extends javax.swing.AbstractActionA simple extension ofAbstractActionthat puts aKeyStrokeinto itsACCELERATOR_KEYfield. This field is read when the action is attached to aJMenuItem.- See Also:
JMenuItem.setAccelerator( KeyStroke ),JMenuItem.configurePropertiesFromAction( Action ),AbstractButton.setAction( Action ), Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MenuAction()Constructs a newMenuActionwithout name and accelerator key.MenuAction(java.lang.String text)Constructs a newMenuActionwithout accelerator key.MenuAction(java.lang.String text, javax.swing.KeyStroke shortcut)Constructs a newMenuActionwith the given text and accelerator shortcut which will be used when the action is attached to aJMenuItem.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidactionPerformed(java.awt.event.ActionEvent e)voiddeinstallFrom(javax.swing.JComponent c, int condition)Deinstalls this action from the keyboard input and action map of the given component.voidinstallOn(javax.swing.JComponent c, int condition)Installs this action on the keyboard input and action map of the given component.voidmimic(javax.swing.Action a)Copies the mappings of a givenActionto thisAction.-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Constructor Detail
-
MenuAction
public MenuAction(java.lang.String text, javax.swing.KeyStroke shortcut)Constructs a newMenuActionwith the given text and accelerator shortcut which will be used when the action is attached to aJMenuItem.- Parameters:
text- text to display in the menu itemshortcut-KeyStrokefor the menu item's accelerator ornull
-
MenuAction
public MenuAction(java.lang.String text)
Constructs a newMenuActionwithout accelerator key.- Parameters:
text- text to display in the menu item
-
MenuAction
public MenuAction()
Constructs a newMenuActionwithout name and accelerator key.
-
-
Method Detail
-
mimic
public void mimic(javax.swing.Action a)
Copies the mappings of a givenActionto thisAction. The entries which are copied are name, key short cuts and descriptions. Therefore a menu item carrying this action will look exactly like the one associated with the passed in action. Also the enabled flag is toggled accordingly.- Parameters:
a- anActionfrom which to copy the mapping entries
-
installOn
public void installOn(javax.swing.JComponent c, int condition)Installs this action on the keyboard input and action map of the given component.- Parameters:
c- the component to install the action oncondition- either ofJComponent.WHEN_FOCUSED,JComponent.WHEN_IN_FOCUSED_WINDOW, orJComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT.
-
deinstallFrom
public void deinstallFrom(javax.swing.JComponent c, int condition)Deinstalls this action from the keyboard input and action map of the given component.- Parameters:
c- the component to remove the action fromcondition- either ofJComponent.WHEN_FOCUSED,JComponent.WHEN_IN_FOCUSED_WINDOW, orJComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT.
-
actionPerformed
public abstract void actionPerformed(java.awt.event.ActionEvent e)
-
-