# Class AbstractControlFactory<F extends AbstractControlFactory<?,?>, C extends Control>

java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<F, C, Composite>
org.eclipse.jface.widgets.AbstractControlFactory<F,C>

Type Parameters:
  `F` - factory
  `C` - control

Direct Known Subclasses:
  `AbstractCompositeFactory, ButtonFactory, DateTimeFactory, LabelFactory, LinkFactory, SashFactory, SashFormFactory, SpinnerFactory, TableFactory, TextFactory, TreeFactory`

@NoExtend public abstract class AbstractControlFactory<F extends AbstractControlFactory<?,?>, C extends Control> extends AbstractWidgetFactory<F, C, Composite>
Abstract factory for controls. Factories for widgets that inherit from Control should extend this factory to handle the properties of Control itself, like enabled or tool tip.

Since:
  3.18

## Method Summary

Modifier and Type
Method
Description
`F`
`background(Color color)`
Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
`F`
`enabled(boolean enabled)`
Enables the receiver if the argument is true, and disables it otherwise.
`F`
`font(Font font)`
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
`F`
`foreground(Color color)`
Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
`F`
`layoutData(Object layoutData)`
Sets the layout data associated with the receiver to the argument.
`F`
`orientation(int orientation)`
Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
`F`
`supplyLayoutData(Supplier<?> layoutDataSupplier)`
Sets a `Supplier` for the creation of layout data associated with the receiver.
`F`
`tooltip(String tooltipText)`
Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.

### Methods inherited from class AbstractWidgetFactory

`addProperty, cast, create, data, data`

### Methods inherited from class Object

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

## Method Details

### tooltip

public F tooltip(String tooltipText)
Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown. The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.

Parameters:
  `tooltipText` - the tool tip text
Returns:
  this
See Also:
  - `Control.setToolTipText(String)`

### enabled

public F enabled(boolean enabled)
Enables the receiver if the argument is true, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Parameters:
  `enabled` - the enabled state
Returns:
  this
See Also:
  - `Control.setEnabled(boolean)`

### supplyLayoutData

public F supplyLayoutData(Supplier<?> layoutDataSupplier)
Sets a `Supplier` for the creation of layout data associated with the receiver. The supplier should always create a new instance of the layoutData in order to make this factory reusable, because each and every control needs its own unique layoutData.

    GridDataFactory gridDataFactory = GridDataFactory.fillDefaults().grab(true, false);
    ButtonFactory.newButton(SWT.PUSH).supplyLayoutData(gridDataFactory::create);

or without GridDataFactory:

    ButtonFactory.newButton(SWT.PUSH).supplyLayoutData(GridData::new);

Parameters:
  `layoutDataSupplier` - `Supplier` creating a new layout data instance on every call
Returns:
  this
See Also:
  - `Control.setLayoutData(Object)`
  - `layoutData(Object)`

### layoutData

public F layoutData(Object layoutData)
Sets the layout data associated with the receiver to the argument. Sufficient for one time usage of this factory.

    GridData gd = new GridData(GridData.FILL_BOTH);
    ButtonFactory.newButton(SWT.PUSH).layoutData(gd);

In case this factory should be reused several time consider the usage of `supplyLayoutData(Supplier)`.

Parameters:
  `layoutData` - the layout data for the receiver.
Returns:
  this
See Also:
  - `Control.setLayoutData(Object)`

### font

public F font(Font font)
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.

Parameters:
  `font` - the font
Returns:
  this
See Also:
  - `Control.setFont(Font)`

### foreground

public F foreground(Color color)
Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

Parameters:
  `color` - the color
Returns:
  this
See Also:
  - `Control.setForeground(Color)`

### background

public F background(Color color)
Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

Parameters:
  `color` - the color
Returns:
  this
See Also:
  - `Control.setBackground(Color)`

### orientation

public F orientation(int orientation)
Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.

Parameters:
  `orientation` - the orientation style
Returns:
  this
See Also:
  - `Control.setOrientation(int)`