HELP! Filling ActionGroup with items from a List of Strings

15 views
Skip to first unread message

Felipe Aumann

unread,
Sep 16, 2021, 12:41:31 AM9/16/21
to ControlsFX
As far as I can tell, the only way populate an ActionGroup is hard coding every item in it:

private Collection<? extends Action> action = Arrays.asList(
                              new ActionGroup("Group 1",
                              new DummyAction("Action 1")),
                              new DummyAction("Action 2"),
                              new DummyAction("Action 3")) );

private static class DummyAction extends Action{
public DummyAction(String name){ super(name); } } }

It would be great if I could place items from a List into an ActionGroup, something like that:

List<String> list = new ArrayList<>();
list.add("Action1");
list.add("Action2");
list.add("Action3");
private Collection<? extends Action> action = Arrays.asList(
new ActionGroup("Group 1", new DummyAction(list)));

There are no resources suggesting whether it is possible or not, at least I couldn't find it in any forum or even in the FXSampler project (which has all ControlsFX content samples).

Any thoughts?

Eugene Ryzhikov

unread,
Sep 16, 2021, 12:47:48 AM9/16/21
to control...@googlegroups.com
Please take a look at JavaDoc 

As you can see, there are two constructors there, which allow you to pass any collection of actions into it.

Eugene

From: control...@googlegroups.com <control...@googlegroups.com> on behalf of Felipe Aumann <felipe...@gmail.com>
Sent: Wednesday, September 15, 2021 11:21:45 PM
To: ControlsFX <control...@googlegroups.com>
Subject: [ControlsFX] HELP! Filling ActionGroup with items from a List of Strings
 
--
You received this message because you are subscribed to the Google Groups "ControlsFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to controlsfx-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/controlsfx-dev/a7f1efe2-a3f0-495b-9d7d-86d74ddee5aan%40googlegroups.com.

Mark Schmieder

unread,
Apr 1, 2023, 2:58:38 AM4/1/23
to ControlsFX
Additionally, if you need some lazy-init behavior due to application logic or run-time flexibility, you can also call the public getActions() method and reset the contents of the list.
Reply all
Reply to author
Forward
0 new messages