Class CompositeFactory


public final class CompositeFactory extends AbstractCompositeFactory<CompositeFactory,Composite>
This class provides a convenient shorthand for creating and initializing Composite. This offers several benefits over creating Composite normal way:
  • The same factory can be used many times to create several Composite instances
  • The setters on CompositeFactory all return "this", allowing them to be chained
Since:
3.18
  • Method Details

    • newComposite

      public static CompositeFactory newComposite(int style)
      Creates a new CompositeFactory with the given style. Refer to Composite(Composite, int) for possible styles.
      Returns:
      a new CompositeFactory instance
    • supplyLayout

      public CompositeFactory supplyLayout(Supplier<Layout> layoutSupplier)
      Sets a Supplier for the creation of layout associated with the receiver. The supplier should always create a new instance of the layout in order to make this factory reusable
       GridLayoutFactory gridFactory = GridLayoutFactory.fillDefaults();
       CompositeFactory.newComposite(SWT.BODER).supplyLayout(gridFactory::create);
       
      or without GridDataFactory:
       CompositeFactory.newComposite(SWT.BODER).supplyLayout(GridLayout::new);
       
      Parameters:
      layoutSupplier - Supplier creating a new layout instance on every call
      Returns:
      this
      Since:
      3.22
      See Also: