public class ActionContainerFactory extends Object
For a menu or submenu, the first element in the action-list represents a menu and subsequent elements represent menu items or separators (if null).
This class can be used as a general component factory which will construct
components from Actions if the create<comp>(Action,...)
methods are used.
ActionManager
Constructor | Description |
---|---|
ActionContainerFactory() |
Constructs an container factory which uses the default
ActionManager.
|
ActionContainerFactory(ActionMap manager) |
Constructs an container factory which uses managed actions.
|
Modifier and Type | Method | Description |
---|---|---|
void |
configureButton(JToggleButton button,
AbstractActionExt a,
ButtonGroup group) |
|
protected void |
configureButtonFromExtActionProperties(AbstractButton button,
Action action) |
This method will be called after buttons created from an action.
|
protected void |
configureMenuItemFromExtActionProperties(JMenuItem menuItem,
Action action) |
This method will be called after menu items are created.
|
void |
configureSelectableButton(AbstractButton button,
AbstractActionExt a,
ButtonGroup group) |
method to configure a "selectable" button from the given AbstractActionExt.
|
AbstractButton |
createButton(Object id,
JComponent container) |
Creates, configures and returns an AbstractButton.
|
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(Object[] actionIds) |
Creates and returns a menu from a List which represents actions, separators
and sub-menus.
|
JMenu |
createMenu(List<?> list) |
Creates and returns a menu from a List which represents actions, separators
and sub-menus.
|
JMenuBar |
createMenuBar(Object[] actionIds) |
Constructs a menu tree from a list of actions or lists of lists or actions.
|
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) |
Deprecated.
API will be made private; see Issue #313
|
JPopupMenu |
createPopup(Object[] list) |
Constructs a popup menu from an array of action ids.
|
JPopupMenu |
createPopup(List<?> list) |
Constructs a popup menu from a list of action ids.
|
JToolBar |
createToolBar(Object[] list) |
Constructs a toolbar from an action-list id.
|
JToolBar |
createToolBar(List<?> list) |
Constructs a toolbar from an action-list id.
|
ActionMap |
getActionManager() |
Gets the ActionManager instance.
|
void |
setActionManager(ActionMap manager) |
Sets the ActionManager instance that will be used by this
ActionContainerFactory
|
public ActionContainerFactory()
public ActionContainerFactory(ActionMap manager)
manager
- use the actions managed with this manager for
constructing ui componenents.public ActionMap getActionManager()
setActionManager(javax.swing.ActionMap)
public void setActionManager(ActionMap manager)
public JToolBar createToolBar(Object[] list)
list
- a list of action ids used to construct the toolbar.public JToolBar createToolBar(List<?> list)
list
- a list of action ids used to construct the toolbar.public JPopupMenu createPopup(Object[] list)
list
- an array of action ids used to construct the popup.public JPopupMenu createPopup(List<?> list)
list
- a list of action ids used to construct the popup.public JMenuBar createMenuBar(Object[] actionIds)
actionIds
- an array which represents the root item.public JMenuBar createMenuBar(List<?> list)
list
- a list which represents the root item.public JMenu createMenu(Object[] actionIds)
actionIds
- an array of action ids used to construct the menu and menu items.
the first element represents the action used for the menu,public JMenu createMenu(List<?> list)
list
- a list of action ids used to construct the menu and menu items.
the first element represents the action used for the menu,@Deprecated public JMenuItem createMenuItem(Action action, JComponent container)
action
- a mangaged Actioncontainer
- the parent container may be null for non-group actions.public JMenuItem createMenuItem(Action action)
action
- an action used to create the menu itempublic AbstractButton createButton(Object id, JComponent container)
id
- the identifercontainer
- the JComponent which parents the group, if any.public AbstractButton createButton(Action action, JComponent container)
action
- an action used to create the buttoncontainer
- the parent container to uniquely identify
grouped components or nullpublic AbstractButton createButton(Action action)
action
- an action used to create the buttonpublic void configureButton(JToggleButton button, AbstractActionExt a, ButtonGroup group)
button
- a
- group
- public void configureSelectableButton(AbstractButton button, AbstractActionExt a, ButtonGroup group)
It's up to the client to only pass in button's where selected and/or the group property makes sense. PENDING: the group properties are yet untested. PENDING: think about automated unconfig.
button
- where selected makes sensea
- group
- the button should be added to.IllegalArgumentException
- if the given action doesn't have the state flag set.protected void configureButtonFromExtActionProperties(AbstractButton button, Action action)
button
- the button to be configuredaction
- the action used to construct the menu item.protected void configureMenuItemFromExtActionProperties(JMenuItem menuItem, Action action)
menuItem
- the menu item to be configuredaction
- the action used to construct the menu item.Copyright © 2018. All rights reserved.