About Actions in the Swing Application Framework
See Also
- The Swing Application Framework (JSR 296) is no longer developed and will not become part of the official Java Development Kit as was originally planned. It is still included in the IDE and you can use this library as it is, but no further development is expected. If you are looking for a Swing-based application framework, consider using the NetBeans Platform.
The main difference between the Swing Application Framework and the NetBeans Platform
in this regard is scope. The Swing Application Framework is more lightweight and
easier to get started with. The NetBeans Platform is more full-featured and
better suited for large and extensible applications.
The Swing Application Framework provides support to help you
define and manage actions.
In the framework, an action is a method that is marked with the
&Action annotation. The framework then uses
that method to perform the given action. You can also specify
various attributes for the action that determine things such as
the enabled state of the action, the action's blocking behavior, and
whether the action runs in the background.
In the IDE, you can use
Set Action dialog box to
generate code for actions, including the annotation and any
attributes. In
the Set Action dialog box, you can do the following:
- Set a component to use an action.
- Create skeleton actions.
- Configure user interface properties for the action, such as
the name to appear on the visual component, tool tip text,
and keyboard shortcuts.
- Create a Boolean property to determine whether the
action is enabled.
- Create a Boolean property to determine whether the
action is selected. (This only applies to non-menu components
that have a selected property, such as radio buttons.)
- Set an action to run as a background task.
- Configure an action to block other actions until it completes.
To open the Set Action dialog box, do one of the following things:
- Right-click a component and choose Set Action.
- Select a component and click the ellipsis (...) button next to
its action property in the Properties window.
Notes:
- When you assign an action to a component, that component's
text, toolTipText, and icon properties are set according
to what you have entered in the Set Action dialog box. If you have previously set
these properties for the component, they
will be replaced by what is specified in the Set Action dialog box. However, you
can return to the property sheet for the component and customize the values that
you want for that component. In the running application, the component-specific
properties will be used.
- By default, resources for the action are stored in a .properties
file that has the same name as the action's .java file.
The property keys
are derived from the action name. The affected attributes are text, tooltip,
accelerator, small icon, large icon, blocking title, and blocking message.
- See Also
- About the Swing Application Framework
- About Resources in the Swing Application Framework
- About Java GUIs
- GUI Builder Tasks: Quick Reference
- Designing Java GUIs with the GUI Builder
Legal Notices