org.jfree.ui.action

Class ActionMenuItem


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

Constructor Summary

ActionMenuItem()
Default constructor.
ActionMenuItem(Action action)
Creates a new menu item based on the specified action.
ActionMenuItem(Icon icon)
Creates a menu item with the specified icon.
ActionMenuItem(String text)
Creates a menu item with the specified label.
ActionMenuItem(String text, Icon icon)
Creates a menu item with the specified label and icon.
ActionMenuItem(String text, int i)
Creates a new menu item with the specified label and mnemonic.

Method Summary

Action
getAction()
Returns the assigned action or null if no action has been assigned.
void
setAction(Action newAction)
Assigns the given action to this menuitem.
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.

Constructor Details

ActionMenuItem

public ActionMenuItem()
Default constructor.

ActionMenuItem

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

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.

Method Details

getAction

public Action getAction()
Returns the assigned action or null if no action has been assigned.
Returns:
the action.

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
Parameters:
newAction - the new 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.
Parameters:
b - the new enable-state of this menuitem