Component Factories

GUI Commands makes extensive use of factories allowing easy customisation of the components generated by the library. The factory types are as follows:

  1. ButtonFactory - Used to create general buttons.
  2. MenuFactory - Used to create menus and menu items.
  3. ToolbarFactory - Used to create toolbars and toolbar buttons.

Factories can be configured globally, or on a per command basis or used on a per button basis.

The following example shows installing a custom toolbar factory to be used by all commands and groups:

   ToolbarFactory customFactory = ...;
   GuiCommands.defaults().setToolbarFactory(customFactory);

The following example shows configuring specific command to use a custom button factory:

   ButtonFactory customFactory = ...;
   ActionCommand command = ...;
   command.setButtonFactory(customFactory);

And an example of using a custom menu factory for a particular button:

   MenuFactory customFactory = ...;
   ActionCommand command = ...;
   command.createMenuItem(customFactory);