Changing Widget Placement in FillLayouts

The default of FillLayout positions the widgets horizontally so that widgets appear side by side. If you want the widgets to appear top to bottom, you need to change the style type of the FillLayout.

How do I do that?

Whether the widgets are displayed horizontally (side by side) or vertically (top to bottom) is controlled by passing a style attribute to the FillLayout constructor:

s.setLayout(new FillLayout(SWT.VERTICAL));

If you make this change to FillLayoutExample, it will produce the dialog displayed in Figure 9-3.

The FillLayout SWT.VERTICAL style

Figure 9-3. The FillLayout SWT.VERTICAL style

Get SWT: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.