Using RowLayout (SWT)

The SWT RowLayout layout manager lays out its components in rows, but is more robust than FillLayout.

With RowLayout, you can set the rows to be in vertical or horizontal style. For the horizontal style, widgets are placed to the left and right of each other. In vertical style, widgets are placed above and below each other.

Dropping or moving widgets within a RowLayout works similarly to other layout managers in the visual editor. As you move your cursor on the Design view, a black bar indicates where the widget will be dropped or moved. If the RowLayout is set to the vertical style, a horizontal black bar will be above or below any existing widgets. If the RowLayout is set to the horizontal style, a vertical black bar will show placement to the left or right of existing widgets.

To set the RowLayout options for a container using RowLayout layout manager:

  1. In the Design view or Java Beans view, right-click the container that is using RowLayout and select Customize Layout from the pop-up menu. The Customize Layout window opens.

    Customize Layout window for SWT RowLayout

  2. On the Layout page, specify an orientation for the rows:
    • Horizontal - standard row orientation, left to right:
      SWT RowLayout in horizontal mode
    • Vertical - a top-to-bottom orientation, or column:
      SWT RowLayout in vertical mode
  3. Specify sizes in pixels for the margins and the space between the widgets:
    • Spacing - sets the spacing, or padding, between widgets
    • Margin Height - sets the height in pixels of the top and bottom margins
    • Margin Width - sets the width in pixels of the left and right margins
    • Margin Bottom - sets the size of the bottom margin
    • Margin Left - sets the size of the left margin
    • Margin Right - sets the size of the right margin
    • Margin Top - sets the size of the top margin
    Note: If you set margin height or margin width, then also specify the bottom, top, left, or right margins, the values will cumulate. For example, if you set a margin height of 5 and a margin top of 5, the margin at the top of the row layout will be 10.
  4. Specify other RowLayout options:
    • Fill - specifies that the controls in a row should be all the same height for horizontal layouts, or the same width for vertical layouts
    • Justify - specifies that extra space remaining in the composite will be allocated as margins between the widgets
    • Pack - specifies that all controls in the layout take their preferred size
    • Wrap - specifies that a control will be wrapped to the next row or column if there is insufficient space in the current row or column
Related concepts
Layout managers and containers

(C) Copyright IBM Corporation 1999, 2004. All Rights Reserved.