Class RowLayoutFactory

java.lang.Object
org.eclipse.jface.layout.RowLayoutFactory

public final class RowLayoutFactory extends Object
RowLayoutFactory creates and initializes row layouts. There are two ways to use RowLayoutFactory. Normally, it is used as a shorthand for writing "new RowLayout()" and initializing a bunch of fields. In this case the main benefit is a more concise syntax and the ability to create more than one identical RowLayout from the same factory. Changing a property of the factory will affect future layouts created by the factory, but has no effect on layouts that have already been created.
Since:
3.5
  • Method Details

    • createFrom

      public static RowLayoutFactory createFrom(RowLayout layout)
      Creates a factory that creates copies of the given layout.
      Parameters:
      layout - layout to copy
      Returns:
      a new RowLayoutFactory instance that creates copies of the given layout
    • copy

      public RowLayoutFactory copy()
      Creates a copy of the receiver.
      Returns:
      a copy of the receiver
    • swtDefaults

      public static RowLayoutFactory swtDefaults()
      Creates a RowLayoutFactory that creates RowLayouts with the default SWT values.

      Initial values are:

      • margins(0,0)
      • extendedMargins(3,3,3,3)
      • wrap(true)
      • pack(true)
      • fill(false)
      • justify(false)
      • spacing(3)
      Returns:
      a RowLayoutFactory that creates RowLayouts as though created with their default constructor
      See Also:
    • fillDefaults

      public static RowLayoutFactory fillDefaults()
      Creates a RowLayoutFactory that creates RowLayouts with no margins, fill behavior, and default dialog spacing.

      Initial values are:

      • margins(0,0)
      • extendedMargins(0,0,0,0)
      • wrap(true)
      • pack(true)
      • fill(false)
      • justify(false)
      • spacing(LayoutConstants.getSpacing().x
      Returns:
      a RowLayoutFactory that creates RowLayouts with no margins
      See Also:
    • spacing

      public RowLayoutFactory spacing(int spacing)
      Sets the spacing for layouts created with this factory. The spacing is the distance between items within the layout.
      Parameters:
      spacing - spacing (pixels)
      Returns:
      this
      See Also:
    • margins

      public RowLayoutFactory margins(Point margins)
      Sets the margins for layouts created with this factory. The margins are the distance between the outer cells and the edge of the layout.
      Parameters:
      margins - margin size (pixels)
      Returns:
      this
      See Also:
    • margins

      public RowLayoutFactory margins(int width, int height)
      Sets the margins for layouts created with this factory. The margins specify the number of pixels of horizontal and vertical margin that will be placed along the left/right and top/bottom edges of the layout. Note that these margins will be added to the ones specified by extendedMargins(int, int, int, int).
      Parameters:
      width - margin width (pixels)
      height - margin height (pixels)
      Returns:
      this
      See Also:
    • extendedMargins

      public RowLayoutFactory extendedMargins(int left, int right, int top, int bottom)
      Sets the margins for layouts created with this factory. The margins specify the number of pixels of horizontal and vertical margin that will be placed along the left, right, top, and bottom edges of the layout. Note that these margins will be added to the ones specified by margins(int, int).
      Parameters:
      left - left margin size (pixels)
      right - right margin size (pixels)
      top - top margin size (pixels)
      bottom - bottom margin size (pixels)
      Returns:
      this
      Since:
      3.3
      See Also:
    • fill

      public RowLayoutFactory fill(boolean fill)
      Fill specifies whether the controls in a row should be all the same height for horizontal layouts, or the same width for vertical layouts.
      Parameters:
      fill - the fill status
      Returns:
      this
    • center

      public RowLayoutFactory center(boolean center)
      Center specifies whether the controls in a row should be centered vertically in each cell for horizontal layouts, or centered horizontally in each cell for vertical layouts.
      Parameters:
      center - the center status
      Returns:
      this
      Since:
      3.20
    • justify

      public RowLayoutFactory justify(boolean justify)
      Justify specifies whether the controls in a row should be fully justified, with any extra space placed between the controls.
      Parameters:
      justify - the justify status
      Returns:
      this
    • pack

      public RowLayoutFactory pack(boolean pack)
      Pack specifies whether all controls in the layout take their preferred size. If pack is false, all controls will have the same size which is the size required to accommodate the largest preferred height and the largest preferred width of all the controls in the layout.
      Parameters:
      pack - the pack status
      Returns:
      this
    • wrap

      public RowLayoutFactory wrap(boolean wrap)
      Wrap specifies whether a control will be wrapped to the next row if there is insufficient space on the current row.
      Parameters:
      wrap - the wrap status
      Returns:
      this
    • type

      public RowLayoutFactory type(int type)
      type specifies whether the layout places controls in rows or columns. Possible values are:
      • HORIZONTAL: Position the controls horizontally from left to right
      • VERTICAL: Position the controls vertically from top to bottom
      Parameters:
      type - One of SWT.HORIZONTAL or SWT.VERTICAL
      Returns:
      this
      Throws:
      IllegalArgumentException - if type is not one of HORIZONTAL or VERTICAL
    • create

      public RowLayout create()
      Creates a new RowLayout, and initializes it with values from the factory.
      Returns:
      a new initialized RowLayout.
      See Also:
    • applyTo

      public void applyTo(Composite c)
      Creates a new RowLayout and attaches it to the given composite. Does not create the rowData of any of the controls in the composite.
      Parameters:
      c - composite whose layout will be set
      See Also:
    • copyLayout

      public static RowLayout copyLayout(RowLayout layout)
      Copies the given RowLayout instance
      Parameters:
      layout - layout to copy
      Returns:
      a new RowLayout