|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ka2ddo.yaac.pluginapi.AbstractMenuAction
public abstract class AbstractMenuAction
This abstract class functions more or less the same as the javax.swing.AbstractAction class, but is not subclassed from that class, so that it can be used in non-Swing environments (such as Android).
Provider
Field Summary | |
---|---|
static java.lang.String |
ACCELERATOR_KEY
The key used for storing a KeyStroke to be used as the
accelerator for the action. |
static java.lang.String |
ACTION_COMMAND_KEY
The key used to determine the command String for the
ActionEvent that will be created when an
Action is going to be notified as the result of
residing in a Keymap associated with a
JComponent . |
static java.lang.String |
BUTTON_GROUP_NAME
Identifies the ButtonGroup a JRadioButtonMenuItem is associated with. |
static java.lang.String |
DISPLAYED_MNEMONIC_INDEX_KEY
The key used for storing an Integer that corresponds
to the index in the text (identified by the NAME
property) that the decoration for a mnemonic should be rendered at. |
protected boolean |
enabled
Specifies whether action is enabled; the default is true. |
static java.lang.String |
LARGE_ICON_KEY
The key used for storing an Icon . |
static java.lang.String |
LOCALIZED_MENU_HIERARCHY
Identifies the hierarchy path for the JMenu containers of a menu item. |
static java.lang.String |
LONG_DESCRIPTION
The key used for storing a longer String
description for the action, could be used for context-sensitive help. |
static java.lang.String |
MENU_PRIORITY
Identifies the sort priority on the lowest JMenu container for positioning a menu item. |
static java.lang.String |
MNEMONIC_KEY
The key used for storing an Integer that corresponds to
one of the KeyEvent key codes. |
static java.lang.String |
NAME
The key used for storing the String name
for the action, used for a menu or button. |
static java.lang.String |
PRE_LOCALIZE_MENU_TAG_NAME
Identifies a specific menu item in the accumulated hierarchy. |
static java.lang.String |
PRE_LOCALIZED_MENU_HIERARCHY
Identifies the ResourceBundle tags for the hierarchy path for the JMenu containers of a menu item. |
protected java.util.HashMap<java.lang.String,java.lang.Object> |
properties
|
static java.lang.String |
SELECTED_KEY
The key used for storing a Boolean that corresponds
to the selected state. |
static java.lang.String |
SHORT_DESCRIPTION
The key used for storing a short String
description for the action, used for tooltip text. |
static java.lang.String |
SMALL_ICON
The key used for storing a small Icon , such
as ImageIcon . |
Constructor Summary | |
---|---|
AbstractMenuAction(java.lang.String name)
Defines an AbstractMenuAction object with the specified
description string and a default icon. |
|
AbstractMenuAction(java.lang.String nameTag,
java.lang.String[] menuPositionNames)
Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus. |
|
AbstractMenuAction(java.lang.String nameTag,
java.lang.String[] menuPositionNames,
int priority)
Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus. |
|
AbstractMenuAction(java.lang.String nameTag,
java.lang.String[] menuPositionNames,
int priority,
boolean initialState)
Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus. |
|
AbstractMenuAction(java.lang.String nameTag,
java.lang.String[] menuPositionNames,
int priority,
java.lang.String buttonGroupName)
Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus. |
|
AbstractMenuAction(java.lang.String nameTag,
java.lang.String[] menuPositionNames,
java.lang.String buttonGroupName)
Construct an AbstractMenuAction with the specified ResourceBundle lookup tag for the name, and hierarchical position in the JMenus. |
Method Summary | |
---|---|
abstract void |
actionPerformed(java.lang.Object e)
Invoked when an action occurs. |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Supports reporting bound property changes. |
AbstractMenuActionPropertyListener |
getPropertyListener()
Get the currently associated GUI-specific PropertyListener. |
java.lang.Object |
getValue(java.lang.String key)
Gets the Object associated with the specified key. |
boolean |
init(java.lang.Object item,
java.lang.Object view)
Additional processing to be done when the action is attached to the menu structure. |
boolean |
isEnabled()
Returns the enabled state of the Action . |
static int[] |
parseMnemonics(java.lang.String mnemonics)
Convert a localized string of mnemonic letters into an array of ints, suitable for use by the above constructors. |
void |
putValue(java.lang.String key,
java.lang.Object newValue)
Sets one of this object's properties using the associated key. |
void |
setEnabled(boolean newValue)
Sets the enabled state of the Action . |
void |
setPropertyListener(AbstractMenuActionPropertyListener propertyListener)
Specify who should be informed of changes to properties. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PRE_LOCALIZE_MENU_TAG_NAME
public static final java.lang.String PRE_LOCALIZED_MENU_HIERARCHY
public static final java.lang.String LOCALIZED_MENU_HIERARCHY
public static final java.lang.String MENU_PRIORITY
public static final java.lang.String BUTTON_GROUP_NAME
public static final java.lang.String NAME
String
name
for the action, used for a menu or button.
public static final java.lang.String SHORT_DESCRIPTION
String
description for the action, used for tooltip text.
public static final java.lang.String LONG_DESCRIPTION
String
description for the action, could be used for context-sensitive help.
public static final java.lang.String SMALL_ICON
Icon
, such
as ImageIcon
. This is typically used with
menus such as JMenuItem
.
If the same Action
is used with menus and buttons you'll
typically specify both a SMALL_ICON
and a
LARGE_ICON_KEY
. The menu will use the
SMALL_ICON
and the button will use the
LARGE_ICON_KEY
.
public static final java.lang.String ACTION_COMMAND_KEY
String
for the
ActionEvent
that will be created when an
Action
is going to be notified as the result of
residing in a Keymap
associated with a
JComponent
.
public static final java.lang.String ACCELERATOR_KEY
KeyStroke
to be used as the
accelerator for the action.
public static final java.lang.String MNEMONIC_KEY
Integer
that corresponds to
one of the KeyEvent
key codes. The value is
commonly used to specify a mnemonic. For example:
myAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A)
sets the mnemonic of myAction
to 'a'.
public static final java.lang.String SELECTED_KEY
Boolean
that corresponds
to the selected state. This is typically used only for components
that have a meaningful selection state. For example,
JRadioButton
and JCheckBox
make use of
this but instances of JMenu
don't.
This property differs from the others in that it is both read
by the component and set by the component. For example,
if an Action
is attached to a JCheckBox
the selected state of the JCheckBox
will be set from
that of the Action
. If the user clicks on the
JCheckBox
the selected state of the JCheckBox
and the Action
will both be updated.
Note: the value of this field is prefixed with 'Swing' to
avoid possible collisions with existing Actions
.
public static final java.lang.String DISPLAYED_MNEMONIC_INDEX_KEY
Integer
that corresponds
to the index in the text (identified by the NAME
property) that the decoration for a mnemonic should be rendered at. If
the value of this property is greater than or equal to the length of
the text, it will treated as -1.
Note: the value of this field is prefixed with 'Swing' to
avoid possible collisions with existing Actions
.
public static final java.lang.String LARGE_ICON_KEY
Icon
. This is typically
used by buttons, such as JButton
and
JToggleButton
.
If the same Action
is used with menus and buttons you'll
typically specify both a SMALL_ICON
and a
LARGE_ICON_KEY
. The menu will use the
SMALL_ICON
and the button the LARGE_ICON_KEY
.
Note: the value of this field is prefixed with 'Swing' to
avoid possible collisions with existing Actions
.
protected boolean enabled
protected java.util.HashMap<java.lang.String,java.lang.Object> properties
Constructor Detail |
---|
public AbstractMenuAction(java.lang.String name)
AbstractMenuAction
object with the specified
description string and a default icon.
name
- already localized String name of action (to appear on menu element)public AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames)
nameTag
- lookup String for the name of this action in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the parent menu name stringspublic AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent JMenus to contain the generated JMenuItempriority
- int relative priority of this menu item relative to otherpublic AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority, boolean initialState)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent JMenus to contain the generated JMenuItempriority
- int relative priority of this menu item relative to otherinitialState
- initial state of JCheckBoxMenuItem to be createdpublic AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, java.lang.String buttonGroupName)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent JMenus to contain the generated JRadioButtonMenuItembuttonGroupName
- String name of ButtonGroup this JRadioButtonMenuItempublic AbstractMenuAction(java.lang.String nameTag, java.lang.String[] menuPositionNames, int priority, java.lang.String buttonGroupName)
nameTag
- lookup String for the above name in ResourceBundlesmenuPositionNames
- array of Strings identifying the ResourceBundle tags for the menu name strings
of the parent JMenus to contain the generated JRadioButtonMenuItempriority
- int relative priority of this menu item relative to other
menu items on its lowest JMenubuttonGroupName
- String name of ButtonGroup this JRadioButtonMenuItemMethod Detail |
---|
public boolean init(java.lang.Object item, java.lang.Object view)
item
- GUI-specific menu item that is associated with the AbstractMenuAction subclassview
- GUI window containing this menu.
MainFrame.buildMenus(java.util.ArrayList, javax.swing.JMenuBar, java.awt.Window)
public abstract void actionPerformed(java.lang.Object e)
e
- UI-specific Object describing the actionpublic java.lang.Object getValue(java.lang.String key)
Object
associated with the specified key. This
arranges for value substitution from ResourceBundles at menu creation
time (after all the alternate ResourceBundle variants have been placed
upon the classpath).
key
- a string containing the specified key
Object
stored with this key; if there
are no keys, it will return null
public void putValue(java.lang.String key, java.lang.Object newValue)
PropertyChangeEvent
is sent
to listeners.
key
- a String
containing the keynewValue
- an Object
valuepublic boolean isEnabled()
Action
. When enabled,
any component associated with this object is active and
able to fire this object's actionPerformed
method.
Action
is enabledpublic void setEnabled(boolean newValue)
Action
. When enabled,
any component associated with this object is active and
able to fire this object's actionPerformed
method.
If the value has changed, a PropertyChangeEvent
is sent
to listeners.
newValue
- true to enable this Action
, false to disable itpublic void setPropertyListener(AbstractMenuActionPropertyListener propertyListener)
propertyListener
- AbstractMenuActionPropertyListenerpublic AbstractMenuActionPropertyListener getPropertyListener()
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
PropertyChangeEvent
to any registered
PropertyChangeListeners
.
propertyName
- String name of property that was changedoldValue
- former value of propertynewValue
- current value of propertypublic static int[] parseMnemonics(java.lang.String mnemonics)
mnemonics
- String of mnemonic letters
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |