Package org.jdesktop.application
Class ApplicationActionMap
java.lang.Object
javax.swing.ActionMap
org.jdesktop.application.ApplicationActionMap
- All Implemented Interfaces:
Serializable
An
ActionMap class where each entry
corresponds to an @Action method from a single
actionsClass (i.e. a class that contains one or more
@Actions). Each entry's key is the @Action's
name (the method name by default), and the value is an
ApplicationAction that calls the @Actions method.
For example, the code below prints "Hello World":
public class HelloWorldActions {
public @Action void Hello() { System.out.print("Hello "); }
public @Action void World() { System.out.println("World"); }
}
// ...
ApplicationActionMap appAM = new ApplicationActionMap(SimpleActions.class);
ActionEvent e = new ActionEvent("no src", ActionEvent.ACTION_PERFORMED, "no cmd");
appAM.get("Hello").actionPerformed(e);
appAM.get("World").actionPerformed(e);
If a ResourceMap is provided then each
ApplicationAction's (putValue, getValue) properties
are initialized from the ResourceMap.
- Author:
- Hans Muller (Hans.Muller@Sun.COM)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionApplicationActionMap(ApplicationContext context, Class actionsClass, Object actionsObject, ResourceMap resourceMap) CreatesApplicationActionMapobject. -
Method Summary
Modifier and TypeMethodDescriptionfinal ClassReturns the base class for actions retrievalfinal ObjectReturns the object with actionsfinal ApplicationContextReturns theApplicationContextAll of the@ProxyActionsrecursively defined by thisApplicationActionMapand its parent ancestors.
-
Constructor Details
-
ApplicationActionMap
public ApplicationActionMap(ApplicationContext context, Class actionsClass, Object actionsObject, ResourceMap resourceMap) CreatesApplicationActionMapobject.The created action map will contain actions which are defined in the
actionsObjectand all its ancestors up to theactionsClass. IfactionsClassis a type of theactionsObjectthen actions only from this class will be added to the map.- Parameters:
context- the Application contextactionsClass- a super class for theactionsObject. Actions will be retrieved starting from this class.actionsObject- the object to be scanned for the actions.resourceMap- theResourceMapto be used for those actions
-
-
Method Details
-
getContext
Returns theApplicationContext- Returns:
- the
ApplicationContext
-
getActionsClass
Returns the base class for actions retrieval- Returns:
- the base class for actions retrieval
-
getActionsObject
Returns the object with actions- Returns:
- the object with actions
-
getProxyActions
All of the@ProxyActionsrecursively defined by thisApplicationActionMapand its parent ancestors.Returns a read-only list of the
@ProxyActionsdefined by thisApplicationActionMap'sactionClassand, recursively, by thisApplicationActionMap'sparent. If there are no proxyActions, an empty list is returned.- Returns:
- a list of all the proxyActions for this
ApplicationActionMap
-