Class ActionMenuItem

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, MenuElement, SwingConstants

public class ActionMenuItem extends JMenuItem
The ActionMenuItem is used to connect an Action and its properties to an MenuItem.

This functionality is already implemented in JDK 1.3 but needed for JDK 1.2.2 compatibility.

Author:
Thomas Morgner
See Also:
  • Constructor Details

    • ActionMenuItem

      public ActionMenuItem()
      Default constructor.
    • ActionMenuItem

      public ActionMenuItem(Icon icon)
      Creates a menu item with the specified icon.
      Parameters:
      icon - the icon.
    • ActionMenuItem

      public ActionMenuItem(String text)
      Creates a menu item with the specified label.
      Parameters:
      text - the label.
    • ActionMenuItem

      public ActionMenuItem(String text, Icon icon)
      Creates a menu item with the specified label and icon.
      Parameters:
      text - the label.
      icon - the icon.
    • ActionMenuItem

      public ActionMenuItem(String text, int i)
      Creates a new menu item with the specified label and mnemonic.
      Parameters:
      text - the label.
      i - the mnemonic.
    • ActionMenuItem

      public ActionMenuItem(Action action)
      Creates a new menu item based on the specified action.
      Parameters:
      action - the action.
  • Method Details

    • getAction

      public Action getAction()
      Returns the assigned action or null if no action has been assigned.
      Overrides:
      getAction in class AbstractButton
      Returns:
      the action.
    • setEnabled

      public void setEnabled(boolean b)
      Enables and disables this button and if an action is assigned to this menuitem the propertychange is forwarded to the assigned action.
      Overrides:
      setEnabled in class JMenuItem
      Parameters:
      b - the new enable-state of this menuitem
    • setAction

      public void setAction(Action newAction)
      Assigns the given action to this menuitem. The properties of the action will be assigned to the menuitem. If an previous action was set, the old action is unregistered.

      • NAME - specifies the menuitem text
      • SMALL_ICON - specifies the menuitems icon
      • MNEMONIC_KEY - specifies the menuitems mnemonic key
      • ACCELERATOR_KEY - specifies the menuitems accelerator
      Overrides:
      setAction in class AbstractButton
      Parameters:
      newAction - the new action