|
| 1 | +package com.vogella.swt.widgets.ctabfolder; |
| 2 | + |
| 3 | +import org.eclipse.swt.SWT; |
| 4 | +import org.eclipse.swt.custom.CTabFolder; |
| 5 | +import org.eclipse.swt.custom.CTabItem; |
| 6 | +import org.eclipse.swt.layout.GridData; |
| 7 | +import org.eclipse.swt.layout.GridLayout; |
| 8 | +import org.eclipse.swt.widgets.Display; |
| 9 | +import org.eclipse.swt.widgets.Shell; |
| 10 | +import org.eclipse.swt.widgets.Text; |
| 11 | + |
| 12 | +public class CTabFolderExample { |
| 13 | + public static void main(String[] args) { |
| 14 | + Display display = new Display(); |
| 15 | + Shell shell = new Shell(display); |
| 16 | + |
| 17 | + shell.setLayout(new GridLayout()); |
| 18 | + // SWT.BOTTOM to show at the bottom |
| 19 | + CTabFolder folder = new CTabFolder(shell, SWT.TOP); |
| 20 | + GridData data = new GridData(SWT.FILL, |
| 21 | + SWT.FILL, true, true, |
| 22 | + 2, 1); |
| 23 | + folder.setLayoutData(data); |
| 24 | + CTabItem cTabItem1 = new CTabItem(folder, SWT.NONE); |
| 25 | + cTabItem1.setText("Tab1"); |
| 26 | + CTabItem cTabItem2 = new CTabItem(folder, SWT.NONE); |
| 27 | + cTabItem2.setText("Tab2"); |
| 28 | + CTabItem cTabItem3 = new CTabItem(folder, SWT.NONE); |
| 29 | + cTabItem3.setText("Tab3"); |
| 30 | + CTabItem cTabItem4 = new CTabItem(folder, SWT.NONE); |
| 31 | + cTabItem4.setText("Tab4"); |
| 32 | + |
| 33 | + shell.pack(); |
| 34 | + shell.open(); |
| 35 | + while (!shell.isDisposed()) { |
| 36 | + if (!display.readAndDispatch()) { |
| 37 | + display.sleep(); |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | +} |
0 commit comments