Use FillLayout
The visual editor makes it easy to work with the SWT FillLayout manager.
To work with Fill layout, you need to create a SWT visual class with a Shell or a Composite or another container.
The SWT Fill layout manager simply lays out components in order, filling the entire space of the container. The components do not wrap, but are simply resized to fit the space, unless the verticalScroll or horizontalScroll properties are set.
In addition, the Fill layout has margin height, margin width, and spacing properties that affect the spacing of components within the container.
Also, you can set the type to either vertical or horizontal to dictate how the components are laid out in relation to each other. The following image shows a horizontal FillLayout with margin height, margin width, and spacing each set to 5:
To work with FillLayout:
- Select your SWT container, such as Shell or Composite.
- In the Properties view, change the layout property to FillLayout.
- Right-click the container and select Customize Layout on the pop-up menu to open the Customize Layout window:
- Set the following properties as required:
- Spacing - sets the distance between components.
- Margin height - sets the distance between the components and the top and bottom inner edges of the container.
- Margin width - sets the distance between the components and the left and right inner edges of the container.
- Choose one of the following options for Fill Orientation:
- Horizontal - sets a left to right orientation
- Vertical - sets a top to bottom orientation
- Optional: To add a scroll bar to the container, set the value for either of the following properties in the Properties view:
- horizontalScroll - adds a scroll bar at the bottom of the container for scrolling horizontally
- verticalScroll - adds a scroll bar at the right side of the container for scrolling vertically
Parent topic
SWT layout managers
Related concepts
Layout managers and containers
Related tasks
Using FormLayout
Using GridLayout (SWT)
Using RowLayout