|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractAction de.michab.mack.ConfigurableAction
A base class that supports configuration and localisation of actions. It
adds the concept of a unique key to the action used to read the
localised attributes from the resource bundle passed to the
setAttributes()
method. The table below lists the configurable
attributes supported by this class:
Key | Comment |
---|---|
NAME |
The Action 's display name. |
TOOLTIP |
Text to be displayed on the Action 's tooltip. |
DESCRIPTION |
A textual description of the Action . |
POPUP |
Flag indicating whether the Action should show up in a
popup menu. |
MENU |
Flag indicating whether the Action is part of the
menu. The value of the flag is the menu group, see ActionManager. |
TOOLBAR |
Flag indicating whether the Action is part of the
application's toolbar. |
KEYSTROKE |
A keystroke that results in an
Action invocation. Displayed also in the application
and context sensitive popup menu. |
ICON |
The icon to be used to represent the Action in menus
and on the toolbar. Note that the value for the ICON key is the path
name of an image file, e.g.
de/michab/apps/lichen/cosexplorer/res/Lumumba.gif |
An ActionManager
is used to create menus and toolbars from
the COnfigurableAction
s that are available in an
application.
ActionManager
,
Serialized FormField Summary |
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
ConfigurableAction(java.lang.String key)
Create an instance for the given key. |
|
ConfigurableAction(java.lang.String key,
boolean enabled)
Create a new action for the given key with the passed enabled setting. |
Method Summary | |
void |
configureFrom(java.util.ResourceBundle b)
A template method to be overridden if an action requires addititional information from the resource file. |
protected static java.awt.Component |
getDialogRoot(java.util.EventObject event)
Computes the default parent component for a dialog displayed by this action. |
java.lang.String |
getKey()
Get the Action 's key. |
javax.swing.JComponent |
getToolbarComponent()
Creates a JComponent that is to be placed on a toolbar. |
protected java.lang.String |
localize(java.util.ResourceBundle b,
java.lang.String key)
Read the value for the passed key from the resource bundle. |
protected java.lang.String |
localize(java.util.ResourceBundle b,
java.lang.String key,
java.lang.String deflt)
Read the value for the passed key from the resource bundle. |
protected javax.swing.Icon |
localizeIcon(java.util.ResourceBundle b,
java.lang.String key)
Return an icon for the given key. |
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.event.ActionListener |
actionPerformed |
Constructor Detail |
public ConfigurableAction(java.lang.String key, boolean enabled)
key
- The new action's key.enabled
- The initial setting for the enabled poperty.public ConfigurableAction(java.lang.String key)
key
- The new action's key.Method Detail |
protected static final java.awt.Component getDialogRoot(java.util.EventObject event)
null
.
event
- The event that triggered the action.
null
in case no
root component could be found.public javax.swing.JComponent getToolbarComponent()
JComponent
that is to be placed on a toolbar. This
default implementation returns a JButton
instance. Override
if other components need to be placed on the toolbar. Restrict yourself
to simple components, since the real estate on a toolbar is rare.
public java.lang.String getKey()
Action
's key.
Action
s key.public void configureFrom(java.util.ResourceBundle b)
b
- The resource bundle to read the configuration from.protected final javax.swing.Icon localizeIcon(java.util.ResourceBundle b, java.lang.String key)
b
- The resource bundle to use for resource lookup.key
- The resource name to lookup.
protected final java.lang.String localize(java.util.ResourceBundle b, java.lang.String key)
null
is returned. Note that the passed key will
be extended with the action's key before resolution is tried. E.g. if the
actions key is A_KEY
and the parameter key's value is
name
then it is tried to resolve A_KEY.name
in
the resource bundle.
b
- The resource bundle used to resolve the key.key
- The key used for resource resolution.
null
if the key could
not be found.Localiser.localise( ResourceBundle, String, String )
protected final java.lang.String localize(java.util.ResourceBundle b, java.lang.String key, java.lang.String deflt)
b
- The resource bundle used to resolve the key.key
- The key used for resource resolution.deflt
- The valuje to return in case the key could not be resolved.
null
if the key could
not be found.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |