Package chemaxon.marvin.swing
Class MAction
java.lang.Object
javax.swing.AbstractAction
chemaxon.marvin.swing.DelegatingAction
chemaxon.marvin.swing.MAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action
Comman base class for Marvin actions.
- Since:
- Marvin 3.1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRemove menu items automatically when the menu becomes invisible.static final intDisables the keyboard shortcut while still displaying its name in the menu.static final intPopup menu item.static final intDo not set the mnemonic.static final intstatic final intUse short `do' label instead of name for the created menu item.static final intUse short `what' label instead of name for the created menu item.Fields inherited from class chemaxon.marvin.swing.DelegatingAction
listenerListFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSets the action state, performs a custom action, then propagates the event.final ComponentAdd menu item to the specified menu.final ComponentAdd menu item to the specified menu.Add menu item to the specified menu.protected voiddoAction(ActionEvent ev) Performs a custom action.Gets the action command string.Is the current action coming from a pop-up menu item?intGets the mnemonic.voidInitializes this action's accelerator keys for the specified component.protected voidinitAccelerators(KeyStroke[] strokes, JComponent c) voidInsert menu item into the specified menu.voidsetActionCommand(String cmd) Sets the action command string.protected voidSets the action state.protected voidsetMenuItem(JMenuItem mi, int flags) voidsetNameAndMnemonic(String label) Sets the label and the mnemonic character.toString()Overrides Object.toString() to ease debugging.Methods inherited from class chemaxon.marvin.swing.DelegatingAction
addActionListener, fireActionPerformed, removeActionListenerMethods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
AUTORM
public static final int AUTORMRemove menu items automatically when the menu becomes invisible.- See Also:
-
NO_MNEMONIC
public static final int NO_MNEMONICDo not set the mnemonic.- See Also:
-
IN_POPUP
public static final int IN_POPUPPopup menu item.- See Also:
-
USE_DO_LABEL
public static final int USE_DO_LABELUse short `do' label instead of name for the created menu item.- Since:
- Marvin 4.0, 07/08/2005
- See Also:
-
USE_WHAT_LABEL
public static final int USE_WHAT_LABELUse short `what' label instead of name for the created menu item.- Since:
- Marvin 4.0, 07/08/2005
- See Also:
-
DISABLE_ACCELERATOR
public static final int DISABLE_ACCELERATORDisables the keyboard shortcut while still displaying its name in the menu.- Since:
- Marvin 4.1, 01/31/2006
- See Also:
-
POPUP
public static final int POPUP- See Also:
-
-
Constructor Details
-
MAction
Creates an action. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
cmd- the action command stringlabel- label for the corresponding components
-
MAction
Creates an action. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
cmd- the action command stringlabel- label for the corresponding componentsaccel- accelerator key or null
-
MAction
Creates an action. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
cmd- the action command stringlabel- label for the corresponding componentsaccel- accelerator key or null
-
-
Method Details
-
setActionCommand
Sets the action command string.- Parameters:
cmd- the action command
-
getActionCommand
Gets the action command string.- Returns:
- the action command
-
setNameAndMnemonic
Sets the label and the mnemonic character. If the label string is of the form "'x'label[DO:]doLabel[WHAT:]whatLabel", then the mnemonic will be x, the menu item label will be label, the `do' label (for `what' menus) will be doLabel and the `what' label (for `do' menus) will be whatLabel. If "'x'" is missing, then the mnemonic is removed. If "[DO:]doLabel" and [WHAT:]whatLabel are optional.- Parameters:
label- the label (optionally containg the mnemonic)- Since:
- Marvin 3.4, 05/01/2004
-
setMenuItem
-
getMnemonic
public int getMnemonic()Gets the mnemonic. The returned value is always an upper case character.- Returns:
- the mnemonic or 0
-
getCurrentTarget
Is the current action coming from a pop-up menu item?- Since:
- Marvin 3.4, 05/11/2004
-
actionPerformed
Sets the action state, performs a custom action, then propagates the event. The code of this method is the following:setActionState(ev);doAction(ev);fireActionPerformed(ev);- Specified by:
actionPerformedin interfaceActionListener- Overrides:
actionPerformedin classchemaxon.marvin.swing.DelegatingAction- Parameters:
ev- action event from a component
-
setActionState
Sets the action state. The default implementation of this method is empty.- Parameters:
ev- action event from a component- Since:
- Marvin 5.0, 11/12/2006
-
doAction
Performs a custom action. The default implementation of this method is empty.- Parameters:
ev- action event from a component- Since:
- Marvin 5.0, 11/12/2006
-
addTo
Add menu item to the specified menu.- Parameters:
menu- the menu- Since:
- Marvin 5.0, 11/18/2006
-
addTo
Add menu item to the specified menu.- Parameters:
menu- the menuflags- options- Since:
- Marvin 3.4, 04/18/2004
- See Also:
-
addTo
Add menu item to the specified menu.- Parameters:
menu- the menuflags- optionst- current action target- Since:
- Marvin 4.0, 07/08/2005
- See Also:
-
insertTo
Insert menu item into the specified menu.- Parameters:
menu- the menui- menu item indexflags- options- Since:
- Marvin 3.4, 04/18/2004
- See Also:
-
initAccelerators
Initializes this action's accelerator keys for the specified component.- Parameters:
c- the component- Since:
- Marvin 5.0, 11/14/2006
-
toString
Overrides Object.toString() to ease debugging. Returns a string consisting of the classname (without the package name!), the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object, followed by the action command in square brackets. -
initAccelerators
-