Adding Widgets to the Tabs
The final step in creating a tabbed folder interface is to add controls to the tab pages.
How do I do that?
Use setControl( )
to add a control to a tab page:
ti1.setControl(new GroupExample(tf, SWT.SHADOW_ETCHED_IN, "Option Group"));
Each TabItem
page can be assigned only one
control. This means that you almost certainly will create a
Composite
for each page, add widgets to that
Composite
to achieve the desired user interface,
and then add the Composite
to the page.
Tip
You should note that when you call setControl( )
to add a control to the page, the parent that is passed to the method
as the first parameter is not the TabItem
upon
which the control is being placed, but rather the
TabFolder
within which the page resides.
This is because TabItem
does not inherit from Composite
, and
can’t be used as a container for other widgets. The
controls that are placed on TabItem
actually
reside on the TabFolder
and are merely being made
visible or not visible as the user navigates the pages.
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.