org.jdesktop.swing.actions
Class ActionContainerFactory

java.lang.Object
  extended byorg.jdesktop.swing.actions.ActionContainerFactory

public class ActionContainerFactory
extends Object

Creates user interface elements based on action-lists managed in an ActionManager.

This class can be used as a general component factory which will construct components from Actions if the create<comp>(Action,...) methods are used.

See Also:
ActionManager

Constructor Summary
ActionContainerFactory(ActionManager manager)
          Creates an container factory which uses managed actions.
 
Method Summary
protected  void configureButton(AbstractButton button, Action action)
          This method will be called after buttons created from an action.
protected static void configureMenuItem(JMenuItem menuItem, Action action)
          This method will be called after menu items are created.
protected  void configureToggleButton(JToggleButton button, Action action)
          This method will be called after toggle buttons are created.
protected static void configureToggleMenuItem(JMenuItem menuItem, Action action)
          This method will be called after toggle type menu items (like JRadioButtonMenuItem and JCheckBoxMenuItem) are created.
 AbstractButton createButton(Action action)
          Creates a button based on the attributes of the action.
 AbstractButton createButton(Action action, JComponent container)
          Creates a button based on the attributes of the action.
 JMenu createMenu(List list)
          Creates and returns a menu from a List which represents actions, separators and sub-menus.
 JMenuBar createMenuBar(List list)
          Constructs a menu tree from a list of actions or lists of lists or actions.
 JMenuItem createMenuItem(Action action)
          Creates a menu item based on the attributes of the action.
 JMenuItem createMenuItem(Action action, JComponent container)
          Creates a menu item based on the attributes of the action element.
 JPopupMenu createPopup(List list)
          Constructs a popup menu from an action-list id.
 JPopupMenu createPopup(Object[] list)
          Constructs a popup menu from an action-list id.
 JToolBar createToolBar(List list)
          Constructs a toolbar from an action-list id.
 JToolBar createToolBar(Object[] list)
          Constructs a toolbar from an action-list id.
 ActionManager getActionManager()
          Gets the ActionManager instance.
 void setActionManager(ActionManager manager)
          Sets the ActionManager instance that will be used by this ActionContainerFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionContainerFactory

public ActionContainerFactory(ActionManager manager)
Creates an container factory which uses managed actions.

Parameters:
manager - use the actions managed with this manager for constructing ui componenents.
Method Detail

getActionManager

public ActionManager getActionManager()
Gets the ActionManager instance. If the ActionManager has not been explicitly set then the default ActionManager instance will be used.

Returns:
the ActionManager used by the ActionContainerFactory.
See Also:
setActionManager(org.jdesktop.swing.actions.ActionManager)

setActionManager

public void setActionManager(ActionManager manager)
Sets the ActionManager instance that will be used by this ActionContainerFactory


createToolBar

public JToolBar createToolBar(Object[] list)
Constructs a toolbar from an action-list id. By convention, the identifier of the main toolbar should be "main-toolbar"

Parameters:
list - a list of action ids used to construct the toolbar.
Returns:
the toolbar or null

createToolBar

public JToolBar createToolBar(List list)
Constructs a toolbar from an action-list id. By convention, the identifier of the main toolbar should be "main-toolbar"

Parameters:
list - a list of action ids used to construct the toolbar.
Returns:
the toolbar or null

createPopup

public JPopupMenu createPopup(Object[] list)
Constructs a popup menu from an action-list id.

Parameters:
list - a list of action ids used to construct the popup.
Returns:
the popup or null

createPopup

public JPopupMenu createPopup(List list)
Constructs a popup menu from an action-list id.

Parameters:
list - a list of action ids used to construct the popup.
Returns:
the popup or null

createMenuBar

public JMenuBar createMenuBar(List list)
Constructs a menu tree from a list of actions or lists of lists or actions.

Parameters:
list - a list which represents the root item.
Returns:
a menu bar which represents the menu bar tree

createMenu

public JMenu createMenu(List list)
Creates and returns a menu from a List which represents actions, separators and sub-menus. The menu constructed will have the attributes from the first action in the List. Subsequent actions in the list represent menu items.

Parameters:
list - a list of action ids used to construct the menu and menu items. the first element represents the action used for the menu,
Returns:
the constructed JMenu or null

createMenuItem

public JMenuItem createMenuItem(Action action,
                                JComponent container)
Creates a menu item based on the attributes of the action element. Will return a JMenuItem, JRadioButtonMenuItem or a JCheckBoxMenuItem depending on the context of the Action.

Parameters:
action - a mangaged Action
container - the parent container may be null for non-group actions.
Returns:
a JMenuItem or subclass depending on type.

createMenuItem

public JMenuItem createMenuItem(Action action)
Creates a menu item based on the attributes of the action. Will return a JMenuItem, JRadioButtonMenuItem or a JCheckBoxMenuItem depending on the context of the Action.

Parameters:
action - an action used to create the menu item
Returns:
a JMenuItem or subclass depending on type.

createButton

public AbstractButton createButton(Action action,
                                   JComponent container)
Creates a button based on the attributes of the action. If the container parameter is non-null then it will be used to uniquely identify the returned component within a ButtonGroup. If the action doesn't represent a grouped component then this value can be null.

Parameters:
action - an action used to create the button
container - the parent container to uniquely identify grouped components or null
Returns:
will return a JButton or a JToggleButton.

createButton

public AbstractButton createButton(Action action)
Creates a button based on the attributes of the action.

Parameters:
action - an action used to create the button
Returns:
will return a JButton or a JToggleButton.

configureToggleButton

protected void configureToggleButton(JToggleButton button,
                                     Action action)
This method will be called after toggle buttons are created. Override for custom configuration but the overriden method should be called first.

Parameters:
button - the button to be configured
action - the action used to construct the menu item.

configureButton

protected void configureButton(AbstractButton button,
                               Action action)
This method will be called after buttons created from an action. Override for custom configuration.

Parameters:
button - the button to be configured
action - the action used to construct the menu item.

configureToggleMenuItem

protected static void configureToggleMenuItem(JMenuItem menuItem,
                                              Action action)
This method will be called after toggle type menu items (like JRadioButtonMenuItem and JCheckBoxMenuItem) are created. Override for custom configuration but the overriden method should be called first.

Parameters:
menuItem - the menu item to be configured
action - the action used to construct the menu item.

configureMenuItem

protected static void configureMenuItem(JMenuItem menuItem,
                                        Action action)
This method will be called after menu items are created. Override for custom configuration.

Parameters:
menuItem - the menu item to be configured
action - the action used to construct the menu item.


Copyright 2004 by Sun Microsystems, Inc. All Rights Reserved.