This Tab Example in Java, will teach you how to create tabs using SWT in Java. After going through the example you will be able to create different tabs with different values on the same page. Just follow the given instruction.
SWT provides the classes TabFolder and TabItem to create tabs. The class TabFolder allows the user to select a page from set of pages which is in the form of tabs. The class TabItem adds a page in the folder in the form of tab. the method item.setText() sets the text to the tabItem.
The method tabFolder.setSize() sets the size of tabFolder. The method getSelection() returns an array of TabItem that are currently selected.
Following code create the tabs:
| for (int i=1; i<5; i++) { TabItem item = new TabItem (tabFolder, SWT.NULL); item.setText ("Tab" + i); |
Here is the code of TabExample.java
import org.eclipse.swt.SWT;
|
Output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Create Tabs in Java using SWT
Post your Comment