public class TestGUI
{
private Shell shell;
/**
* Runs the application
*/
public void run()
{
Display display = new Display();
shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
shell.setText("Test");
Table head = createTable();
TableItem itemHead1 = new TableItem(head, SWT.NONE);
itemHead1.setText(new String[] { "Vorname", "Nachname", "Ort" });
itemHead1.setBackground(new org.eclipse.swt.graphics.Color(this.shell
.getDisplay(), 115, 187, 255));
TableItem itemHead2 = new TableItem(head, SWT.NONE);
itemHead2.setText(new String[] { "Straße", "PLZ", "Land" });
Table table = createTable();
TableItem item1 = new TableItem(table, SWT.NONE);
item1.setText(new String[] { "Tim", "Muster", "Krieger" });
item1.setBackground(new org.eclipse.swt.graphics.Color(this.shell.getDisplay(),
115, 187, 255));
TableItem item12 = new TableItem(table, SWT.NONE);
item12.setText(new String[] { "Im Ander", "73554", "Deutschland" });
TableItem item2 = new TableItem(table, SWT.NONE);
item2.setText(new String[] { "Max", "Werner", "Weitmars" });
item2.setBackground(new org.eclipse.swt.graphics.Color(this.shell.getDisplay(),
115, 187, 255));
TableItem item22 = new TableItem(table, SWT.NONE);
item22.setText(new String[] { "Landerstr", "73880", "Deutschland" });
TableItem item3 = new TableItem(table, SWT.NONE);
item3.setText(new String[] { "Reene", "Miller", "Lorch" });
item3.setBackground(new org.eclipse.swt.graphics.Color(this.shell.getDisplay(),
115, 187, 255));
TableItem item32 = new TableItem(table, SWT.NONE);
item32.setText(new String[] { "Teckstr", "63529", "Deutschland" });
// label.setFont(label.getFont().get);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
private Table createTable()
{
Table t = new Table(shell, SWT.BORDER);
TableColumn tc1 = new TableColumn(t, SWT.CENTER);
TableColumn tc2 = new TableColumn(t, SWT.CENTER);
TableColumn tc3 = new TableColumn(t, SWT.CENTER);
// tc1.setText("Vorname");
// tc2.setText("Nachname");
// tc3.setText("Adresse");
tc1.setWidth(70);
tc2.setWidth(70);
tc3.setWidth(80);
t.setHeaderVisible(false);
t.setLinesVisible(true);
return t;
}
public static void main(String[] args)
{
new TestGUI().run();
}