Class GroupFactory

public class GroupFactory extends AbstractCompositeFactory<GroupFactory,Group>
This class provides a convenient shorthand for creating and initializing Group. This offers several benefits over creating Group normal way:
  • The same factory can be used many times to create several Group instances
  • The setters on GroupFactory all return "this", allowing them to be chained
Example usage:
 Label label = GroupFactory.newGroup(SWT.SHADOW_NONE)//
                .text("My Group") //
                .layoutData(gridData) //

The above example creates a Group with a text and style: SWT.SHADOW_NONE. Finally the group is created in "parent".

 GroupFactory groupFactory = GroupFactory.newGroup(SWT.SHADOW_NONE);
 GroupFactory.text("Group 1").create(parent);
 GroupFactory.text("Group 2").create(parent);
 GroupFactory.text("Group 3").create(parent);

The above example creates three labels using the same instance of LabelFactory.

  • Method Details

    • newGroup

      public static GroupFactory newGroup(int style)
      Creates a new GroupFactory with the given style. Refer to Group(Composite, int) for possible styles.
      a new GroupFactory instance
    • text

      public GroupFactory text(String text)
      Sets the receiver's text, which is the string that will be displayed as the receiver's title, to the argument, which may not be null. The string may include the mnemonic character.

      Mnemonics are indicated by an '&' that causes the next character to be the mnemonic. When the user presses a key sequence that matches the mnemonic, focus is assigned to the first child of the group. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.

      Note: If control characters like '\n', '\t' etc. are used in the string, then the behavior is platform dependent.

      text - the text
      See Also: