Modifier and Type | Required Element and Description |
---|---|
String |
displayName
Display name.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
asynchronous
Shall the action be performed outside of AWT thread.
|
ActionState |
checkedOn
Controls action's enable state.
|
ActionState |
enabledOn
Specifies a property that enables the action for context-sensitive actions.
|
String |
iconBase
Path to image representing the action's icon.
|
boolean |
iconInMenu
Shall the action's icon be visible in menu?
|
String |
key
Shall this action be associated with a particular key in an
ActionMap ? E.g. |
boolean |
lazy
Whether a lazy factory registration from
Actions should be used. |
String |
menuText
Provides the JMenuItem text if one wants to use other than
the name of the action returned by
ActionRegistration.displayName() . |
String |
popupText
Provides the JMenuItem popup text if one wants to use other
than the name of the action returned by
ActionRegistration.displayName() . |
boolean |
surviveFocusChange
Shall the action work on last selection when it was enabled?
|
public abstract String displayName
Bundle.properties
file in the same package.public abstract String menuText
ActionRegistration.displayName()
.Actions.connect(javax.swing.JMenuItem, javax.swing.Action, boolean)
public abstract String popupText
ActionRegistration.displayName()
.Actions.connect(javax.swing.JMenuItem, javax.swing.Action, boolean)
public abstract String iconBase
public abstract boolean iconInMenu
public abstract String key
ActionMap
? E.g. behave like Actions.callback(java.lang.String, javax.swing.Action, boolean, java.lang.String, java.lang.String, boolean)
one?ActionMap
public abstract boolean asynchronous
public abstract boolean surviveFocusChange
public abstract boolean lazy
Actions
should be used.
Most actions can be registered using a lazy factory (see class Javadoc for list), which permits the application to avoid loading the action class unless and until it is actually run. Before then, queries on the name, icon, etc. are serviced using static metadata, which minimizes startup overhead.
In limited cases, using this sort of lazy delegate is impossible or undesirable:
the action needs to export some special key from Action.getValue(java.lang.String)
;
it presents multiple menu items according to dynamic conditions; or for UI reasons
it is preferred to visually disable the action under certain conditions (rather than
leaving it enabled and showing a message if selected under those conditions).
For these special cases,
you may specify lazy=false
to force the action registration to use the
traditional direct registration of an instance of the action, without any lazy factory.
That allows the action to supply arbitrary customized behavior even before it is ever run,
at the expense of overhead when the registration is first encountered (such as when the
main menu bar is populated, or a context menu of a certain kind is first shown).
It is an error to specify lazy=false
on an element which is not assignable
to Action
(e.g. an ActionListener
, or a String
field);
or which requires a context parameter in its constructor (or factory method).
For compatibility, registrations which do not explicitly specify this
attribute but which are on elements assignable to any of the following types
will be registered as if lazy=false
, despite the default value of the attribute
(but a warning will be issued and the attribute should be made explicit):
public abstract ActionState enabledOn
Specify the value if the action should be enabled based on certain property and
its value. See ActionState
for detailed explanation of the
state evaluation and tracking.
public abstract ActionState checkedOn
ActionRegistration.enabledOn()
, type and its property can be used to determine whether the
action is checked or unchecked. See ActionState
for more details.