Package org.eclipse.jface.widgets

# Class GroupFactory

java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<GroupFactory,Group,Composite>
org.eclipse.jface.widgets.AbstractControlFactory<GroupFactory,Group>
org.eclipse.jface.widgets.AbstractCompositeFactory<GroupFactory,Group>
org.eclipse.jface.widgets.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) //
                    .create(parent);

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.

Since:
  3.24

## Method Summary

Modifier and Type
Method
Description
`static GroupFactory`
`newGroup(int style)`
Creates a new GroupFactory with the given style.
`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.

### Methods inherited from class org.eclipse.jface.widgets.AbstractCompositeFactory

`layout`

### Methods inherited from class org.eclipse.jface.widgets.AbstractControlFactory

`background, enabled, font, foreground, layoutData, orientation, supplyLayoutData, tooltip`

### Methods inherited from class org.eclipse.jface.widgets.AbstractWidgetFactory

`addProperty, cast, create, data, data`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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.

Returns:
  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.

Parameters:
  `text` - the text
Returns:
  this
See Also:
  - `Group.setText(String)`