Creating Groups

There are three steps to creating a CommandGroup:

  1. Create the configuration.
  2. Load the configuration.
  3. Create and bind the group.

1. Create the Configuration

CommandGroup configuration is similar to ActionCommands in that it defines both face properties and custom user properties. In addition groups allow you to specify their members list. All group properties must be prefixed with the string group!.

The following shows an example configuration for the group file-group. This group contains the new, open, save, save-as and exit commands. It also adds a separator between the save-as and exit entries:

   group!file-menu@face.text=_File
   group!file-menu@members=new, open, save, save-as, separator, exit

Please read the Group Configuration for more details on the configuration options.

2. Load the Configuration

Group configuration is loaded identically to action commands. In fact you'd often combine your command and group configuration in one file.

   // load the configuration file
   GuiCommands.load("MyGroups");

3. Create and Bind the Group

Finally we need to create the group and bind it to a command container.

   // create and bind our group
   CommandGroup fileGroup = new CommandGroup("file-menu");
   fileGroup.bind(commandConatiner);

   // now we can create buttons and menu items
   JMenuItem fileMenu = fileGroup.createMenuItem();

Binding and command containers are covered in detail in the Containers and Binding section.