Chapter 11. SWT Tabbed Folders
A very common user interface construct is one in which a window is
divided using a notebook format, with tabs allowing easy access to
widgets on each page of the notebook. This construct is usually
referred to as a tabbed folder interface
. The SWT provides classes that make
developing such an interface a simple task. The two classes used for
this purpose are TabFolder
and
TabItem
, both from the
org.eclipse.swt.widgets
package.
An example of a tabbed interface is shown in Figure 11-1.
Figure 11-1. A simple tabbed interface
Clicking each tab reveals a separate page of the notebook, each with its own set of widgets.
Creating an Instance of TabFolder
First, create an instance of the
TabFolder
class that will act as a container for the
tabs.
How do I do that?
Create an instance of TabFolder
just as you do any
other widget:
TabFolder tf = new TabFolder(s, SWT.NONE);
The TabFolder
is added to another container
class—either a Composite
or a
Shell
. In the preceding code, it has been added to
a Shell
object (s
).
TabFolder
has no
styles intrinsic to itself, but you
must still pass in a placeholder for a style.
SWT.NONE
is used for this purpose.
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.