Next: The Action Interface
Up: Swing Component Basics
Previous: Actions
JMenu, JToolBar and JPopupMenu accept actions with their
add() methods (See Fig.
).
When the action is added:
- The container automatically creates a GUI component which can be
customised with add(). I.e.
- JMenu or JPopupMenu creates and returns a
JMenuItem from an Action
- ToolBar creates and returns a JButton
The Action is then paired with the New component in 2 ways(See
Fig.
):
- The component registers a PropertyChangeListener -- for
example if the action is disabled Both components will be disabled
(visually greyed).
- The Action object registers an ActionListener on
all associated components.
Dave Marshall
4/14/1999