Top Description Fields Constructors Methods
org.controlsfx.control.action

public Class ActionGroup

extends Action
Class Inheritance
Imports
java.util.Arrays, .Collection, javafx.collections.FXCollections, .ObservableList, javafx.scene.Node, javafx.scene.control.ContextMenu, .MenuBar, .ToolBar

An ActionGroup (unsurprisingly) groups together zero or more Action instances, allowing for more complex controls like ToolBar, MenuBar and ContextMenu to be automatically generated from the collection of actions inside the ActionGroup. For your convenience, there are a number of utility methods that do precisely this in the ActionUtils class.

Code Examples

Consider the following code example (note that DummyAction is a fake class that extends from (and implements) Action):

// Firstly, create a list of Actions
Collection<? extends Action> actions = Arrays.asList(
    new ActionGroup("Group 1",  new DummyAction("Action 1.1"), 
                                new DummyAction("Action 2.1") ),
    new ActionGroup("Group 2",  new DummyAction("Action 2.1"), 
                                new ActionGroup("Action 2.2", new DummyAction("Action 2.2.1"), 
                                                              new DummyAction("Action 2.2.2")),
                                new DummyAction("Action 2.3") ),
    new ActionGroup("Group 3",  new DummyAction("Action 3.1"), 
                                new DummyAction("Action 3.2") )
  );

  // Use the ActionUtils class to create UI controls from these actions, e.g:
  MenuBar menuBar = ActionUtils.createMenuBar(actions);

  ToolBar toolBar = ActionUtils.createToolBar(actions);

  Label context = new Label("Right-click to see the context menu");
  context.setContextMenu(ActionUtils.createContextMenu(actions));  

The end result of running the code above is shown in the screenshots below (hopefully it goes without saying that within the 'Group 1', 'Group 2' and 'Group 3' options are the 'Action 1.1', etc actions that have been specified in the code above):

MenuBar: Screenshot of ActionGroup in a MenuBar
ToolBar: Screenshot of ActionGroup in a ToolBar
ContextMenu: Screenshot of ActionGroup in a ContextMenu
See Also
Action, ActionUtils

Field Summary

Modifier and TypeField and Description
private final ObservableList<Action>

Constructor Summary

AccessConstructor and Description
public
ActionGroup(String
The text of this Action.
text
,
Action...
Zero or more actions to insert into this ActionGroup.
actions
)

Creates an ActionGroup with the given text as the name of the Action, and zero or more Actions as members of this ActionGroup.

public
ActionGroup(String
The text of this Action.
text
,
Collection<Action>
Collection of actions to insert into this ActionGroup.
actions
)

Creates an ActionGroup with the given text as the name of the Action, and collection of Actions as members of this ActionGroup.

public
ActionGroup(String
The text of this Action.
text
,
Node
The image of this Action.
icon
,
Action...
Zero or more actions to insert into this ActionGroup.
actions
)

Creates an ActionGroup with the given text as the name of the Action, and zero or more Actions as members of this ActionGroup.

public
ActionGroup(String
The text of this Action.
text
,
Node
The image of this Action.
icon
,
Collection<Action>
Collection of actions to insert into this ActionGroup.
actions
)

Creates an ActionGroup with the given text as the name of the Action, and collection of Actions as members of this ActionGroup.

Method Summary

Modifier and TypeMethod and Description
public final ObservableList<Action>
getActions()

The list of Action instances that exist within this ActionGroup.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.controlsfx.control.action.Action:
acceleratorPropertydisabledPropertygetAcceleratorgetEventHandlergetGraphicgetLongTextgetPropertiesgetStylegetStyleClassgetTextgraphicPropertyhandleisDisabledisSelectedlocklongTextPropertyselectedPropertysetAcceleratorsetDisabledsetEventHandlersetGraphicsetLongTextsetSelectedsetStylesetTextstylePropertytextProperty

Field Detail

actionsback to summary
private final ObservableList<Action> actions

Constructor Detail

ActionGroupback to summary
public ActionGroup(String text, Action... actions)

Creates an ActionGroup with the given text as the name of the Action, and zero or more Actions as members of this ActionGroup. Note that it is legitimate to pass in zero Actions to this constructor, and to later set the actions directly into the actions list.

Parameters
text:String

The text of this Action.

actions:Action[]

Zero or more actions to insert into this ActionGroup.

ActionGroupback to summary
public ActionGroup(String text, Collection<Action> actions)

Creates an ActionGroup with the given text as the name of the Action, and collection of Actions as members of this ActionGroup.

Parameters
text:String

The text of this Action.

actions:Collection<Action>

Collection of actions to insert into this ActionGroup.

ActionGroupback to summary
public ActionGroup(String text, Node icon, Action... actions)

Creates an ActionGroup with the given text as the name of the Action, and zero or more Actions as members of this ActionGroup. Note that it is legitimate to pass in zero Actions to this constructor, and to later set the actions directly into the actions list.

Parameters
text:String

The text of this Action.

icon:Node

The image of this Action.

actions:Action[]

Zero or more actions to insert into this ActionGroup.

ActionGroupback to summary
public ActionGroup(String text, Node icon, Collection<Action> actions)

Creates an ActionGroup with the given text as the name of the Action, and collection of Actions as members of this ActionGroup. .

Parameters
text:String

The text of this Action.

icon:Node

The image of this Action.

actions:Collection<Action>

Collection of actions to insert into this ActionGroup.

Method Detail

getActionsback to summary
public final ObservableList<Action> getActions()

The list of Action instances that exist within this ActionGroup. This list may be modified, as shown in the class documentation.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override