Package org.eclipse.jface.widgets

# Class SpinnerFactory

java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<SpinnerFactory,Spinner,Composite>
org.eclipse.jface.widgets.AbstractControlFactory<SpinnerFactory,Spinner>
org.eclipse.jface.widgets.SpinnerFactory

public final class SpinnerFactory extends AbstractControlFactory<SpinnerFactory,Spinner>
This class provides a convenient shorthand for creating and initializing `Spinner`. This offers several benefits over creating Spinner normal way:

- The same factory can be used many times to create several Spinner instances
- The setters on SpinnerFactory all return "this", allowing them to be chained

Note that this class does not extend `AbstractCompositeFactory` even though Spinner extends Composite. This is because Spinner is not supposed to be used like a Composite.

Since:
  3.18

## Method Summary

Modifier and Type
Method
Description
`SpinnerFactory`
`bounds(int minimum, int maximum)`
Sets the minimum and maximum value that the receiver will allow.
`SpinnerFactory`
`increment(int increment, int pageIncrement)`
Sets the amounts (which must be at least one) that the receiver's value will be modified by when the up/down arrows or the page up/down keys are pressed to the argument.
`SpinnerFactory`
`limitTo(int limit)`
Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument.
`static SpinnerFactory`
`newSpinner(int style)`
Creates a new SpinnerFactory with the given style.
`SpinnerFactory`
`onModify(ModifyListener listener)`
Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by calling the modifyText method.
`SpinnerFactory`
`onSelect(Consumer<SelectionEvent> consumer)`
Creates a `SelectionListener` and registers it for the widgetSelected event.

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

### newSpinner

public static SpinnerFactory newSpinner(int style)
Creates a new SpinnerFactory with the given style. Refer to `Spinner(Composite, int)` for possible styles.

Returns:
  a new SpinnerFactory instance

### bounds

public SpinnerFactory bounds(int minimum, int maximum)
Sets the minimum and maximum value that the receiver will allow.

Parameters:
  `minimum` - the minimum
  `maximum` - the maximum
Returns:
  this
See Also:
  - `Spinner.setMinimum(int)`
  - `Spinner.setMaximum(int)`

### increment

public SpinnerFactory increment(int increment, int pageIncrement)
Sets the amounts (which must be at least one) that the receiver's value will be modified by when the up/down arrows or the page up/down keys are pressed to the argument.

Parameters:
  `increment` - the increment (must be greater than zero)
  `pageIncrement` - the page increment (must be greater than zero)
Returns:
  this
See Also:
  - `Spinner.setIncrement(int)`
  - `Spinner.setPageIncrement(int)`

### limitTo

public SpinnerFactory limitTo(int limit)
Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument.

Parameters:
  `limit` - the limit
Returns:
  this
See Also:
  - `Spinner.setTextLimit(int)`

### onSelect

public SpinnerFactory onSelect(Consumer<SelectionEvent> consumer)
Creates a `SelectionListener` and registers it for the widgetSelected event. If the receiver is selected by the user the given consumer is invoked. The `SelectionEvent` is passed to the consumer.

Parameters:
  `consumer` - the consumer whose accept method is called
Returns:
  this
See Also:
  - `Spinner.addSelectionListener(SelectionListener)`
  - `SelectionListener.widgetSelectedAdapter(Consumer)`

### onModify

public SpinnerFactory onModify(ModifyListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by calling the modifyText method.

Can be called several times to add more than one ModifyListener.

Parameters:
  `listener` - the listener which should be notified
Returns:
  this
See Also:
  - `Spinner.addModifyListener(ModifyListener)`
  - `ModifyListener.modifyText(org.eclipse.swt.events.ModifyEvent)`