Class SashFormFactory


public final class SashFormFactory extends AbstractControlFactory<SashFormFactory,SashForm>
This class provides a convenient shorthand for creating and initializing SashForm. This offers several benefits over creating SashForm normal way:
  • The same factory can be used many times to create several SashForm instances
  • The setters on SashFormFactory all return "this", allowing them to be chained
Example usage:
 SashForm sashForm = SashFormFactory.newFormSash(SWT.HORIZONTAL).create(parent);
 Composite c1 = CompositeFactory.newComposite(SWT.NONE).create(sashForm);
 Composite c2 = CompositeFactory.newComposite(SWT.NONE).create(sashForm);
 sashForm.setWeights(new int[] { 30, 70 });
 

The above example creates a horizontal sash. Note that SashForm.setWeights(int[]) can only be called after children have been added to the SashForm. Hence this method is not part of this factory.

 GridDataFactory gridDataFactory = GridDataFactory.swtDefaults();
 SashFactory sashFactory = SashFactory.newSash(SWT.HORIZONTAL).layout(gridDataFactory::create);
 sashFactory.data("Sash 1").create(parent);
 sashFactory.data("Sash 2").create(parent);
 sashFactory.data("Sash 3").create(parent);
 

The above example creates three sashForms using the same instance of SashFormFactory. Note the layout method. A Supplier is used to create unique GridData for every single sash.

Since:
3.21
  • Method Details

    • newSashForm

      public static SashFormFactory newSashForm(int style)
      Creates a new SashFormFactory with the given style. Refer to SashForm(Composite, int) for possible styles.
      Returns:
      a new SashFormFactory instance
    • sashWidth

      public SashFormFactory sashWidth(int width)
      Specify the width of the sashes when the controls in the SashForm are laid out.
      Parameters:
      width - the width of the sashes
      Returns:
      this
      See Also: