Choosing a more capable tab folder
SWT provides org.eclipse.swt.widgets.TabFolder for conventional tabbed interfaces. It maps closely to native platform controls, which makes it familiar but can also limit presentation and behavior to what each operating system offers.
For interfaces that need controls on tabs, close affordances, alternate positioning, or a more Eclipse-like appearance, SWT also provides org.eclipse.swt.custom.CTabFolder. Its setup remains close to the standard widget, making it a practical substitute when an application needs more control.
A minimal standard tab folder
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
TabFolder tabs = new TabFolder(shell, SWT.NONE);
for (int i = 0; i < 6; i++) {
TabItem item = new TabItem(tabs, SWT.NONE);
item.setText("Tab Item " + i);
Text text = new Text(tabs, SWT.BORDER | SWT.MULTI);
text.setText("Content for Item " + i);
item.setControl(text);
}
shell.pack();
shell.open();The custom folder follows the same basic shape. Replace the folder and item classes, then layer in the options the interface needs.
Moving to CTabFolder
CTabFolder tabs = new CTabFolder(shell, SWT.NONE);
for (int i = 0; i < 6; i++) {
CTabItem item = new CTabItem(tabs, SWT.NONE);
item.setText("Tab Item " + i);
Text text = new Text(tabs, SWT.BORDER | SWT.MULTI);
text.setText("Content for Item " + i);
item.setControl(text);
}Useful configuration points
Close controls can be enabled with SWT.CLOSE. The visibility of close affordances on unselected tabs can be adjusted with setUnselectedCloseVisible(). For a bottom-oriented tab strip, combine the style flags with SWT.BOTTOM.
CTabFolder tabs = new CTabFolder(
shell, SWT.CLOSE | SWT.BOTTOM
);
tabs.setUnselectedCloseVisible(false);
tabs.setSimple(false);The final setting above requests a more shaped tab presentation. When tab labels exceed available space, the custom folder also offers an overflow affordance, while the standard folder uses platform-oriented navigation behavior.
Practical takeaway
Choose TabFolder when native conventions are the priority and the interface is uncomplicated. Choose CTabFolder when the application benefits from a richer tab treatment, but keep interaction predictable: establish the initial selection deliberately, handle selection changes at the folder level, and test the result on the environments you support.