Java by API/org.eclipse.swt.widgets/TabItem
new TabItem(TabFolder folder, int style)
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
public class MainClass {
public static void main(String[] a) {
Display d = new Display();
Shell s = new Shell(d);
s.setText("A Tabbed Shell Example");
s.setLayout(new FillLayout());
TabFolder tf = new TabFolder(s, SWT.BORDER);
TabItem ti1 = new TabItem(tf, SWT.BORDER);
ti1.setText("Option Group");
ti1.setControl(new Text(tf, SWT.MULTI));
TabItem ti2 = new TabItem(tf, SWT.BORDER);
ti2.setText("Grid");
ti2.setControl(new Text(tf, SWT.MULTI));
TabItem ti3 = new TabItem(tf, SWT.BORDER);
ti3.setText("Text");
Composite c1 = new Composite(tf, SWT.BORDER);
c1.setLayout(new FillLayout());
Text t = new Text(c1, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
ti3.setControl(c1);
TabItem ti4 = new TabItem(tf, SWT.BORDER);
ti4.setText("Settings");
Composite c2 = new Composite(tf, SWT.BORDER);
c2.setLayout(new RowLayout());
Text t2 = new Text(c2, SWT.BORDER | SWT.SINGLE | SWT.WRAP | SWT.V_SCROLL);
Button b = new Button(c2, SWT.PUSH | SWT.BORDER);
b.setText("Save");
ti4.setControl(c2);
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}
TabItem: setControl(Control control)
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ruposite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
public class MainClass {
public static void main(String[] a) {
Display d = new Display();
Shell s = new Shell(d);
s.setText("A Tabbed Shell Example");
s.setLayout(new FillLayout());
TabFolder tf = new TabFolder(s, SWT.BORDER);
TabItem ti1 = new TabItem(tf, SWT.BORDER);
ti1.setText("Option Group");
ti1.setControl(new Text(tf, SWT.MULTI));
TabItem ti2 = new TabItem(tf, SWT.BORDER);
ti2.setText("Grid");
ti2.setControl(new Text(tf, SWT.MULTI));
TabItem ti3 = new TabItem(tf, SWT.BORDER);
ti3.setText("Text");
Composite c1 = new Composite(tf, SWT.BORDER);
c1.setLayout(new FillLayout());
Text t = new Text(c1, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
ti3.setControl(c1);
TabItem ti4 = new TabItem(tf, SWT.BORDER);
ti4.setText("Settings");
Composite c2 = new Composite(tf, SWT.BORDER);
c2.setLayout(new RowLayout());
Text t2 = new Text(c2, SWT.BORDER | SWT.SINGLE | SWT.WRAP | SWT.V_SCROLL);
Button b = new Button(c2, SWT.PUSH | SWT.BORDER);
b.setText("Save");
ti4.setControl(c2);
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}
TableItem: getBounds(int i)
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
shell.setLayout(new FillLayout());
final Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION
| SWT.HIDE_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Create five columns
for (int i = 0; i < 5; i++) {
TableColumn column = new TableColumn(table, SWT.CENTER);
column.setText("Column " + (i + 1));
column.pack();
}
for (int i = 0; i < 5; i++) {
// Create the row
new TableItem(table, SWT.NONE);
}
table.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
Point pt = new Point(event.x, event.y);
TableItem item = table.getItem(pt);
if (item != null) {
int column = -1;
for (int i = 0, n = table.getColumnCount(); i < n; i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
column = i;
System.out.println(column);
break;
}
}
}
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}