Class TextFactory


public final class TextFactory extends AbstractControlFactory<TextFactory, Text>
This class provides a convenient shorthand for creating and initializing Text. This offers several benefits over creating Text normal way:
  • The same factory can be used many times to create several Text instances
  • The setters on TextFactory all return "this", allowing them to be chained
  • TextFactory accepts a Lambda for SelectionEvent (see onSelect(Consumer))
Example usage:
Text text = new TextFactory(SWT.WRAP)//
                .limitTo(16) //
                .message("Enter credit card number") //
                .layoutData(gridData) //
                .create(parent);

The above example creates a Text with wrapped style, limits it to 16 characters, sets a message and finally creates it in "parent".

TextFactory textFactory = new TextFactory(SWT.NONE);
textFactory.message("Enter text 1").create(parent);
textFactory.message("Enter text 2").create(parent);
textFactory.message("Enter text 3").create(parent);

The above example creates three texts using the same instance of TextFactory.

Since:
3.18