final Table table = new Table(result, SWT.CHECK | SWT.BORDER | SWT.SINGLE |
SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION |
SWT.VIRTUAL);
final String[] items = new String[10];
for (int i = 0, n = items.length; i < n; i++) {
items[i] = "I am item number " + i;
}
// Fünf Tabellenspalten erzeugen - selbsterklärend
TableColumn col1 = new TableColumn(table,SWT.VIRTUAL);
col1.setText("Name");
col1.setWidth(80);
TableColumn col2 = new TableColumn(table,SWT.VIRTUAL);
col2.setText("Ort");
col2.setWidth(80);
TableColumn col3 = new TableColumn(table,SWT.VIRTUAL);
col3.setText("Größe");
col3.setWidth(80);
TableColumn col4 = new TableColumn(table,SWT.VIRTUAL);
col4.setText("Datum");
col4.setWidth(120);
TableColumn col5 = new TableColumn(table,SWT.VIRTUAL);
col5.setText("Übereinstimmung in %");
col5.setWidth(120);
// Spaltenköpfe und Trennlinien sichtbar machen
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Drei Tabellenreihen erzeugen
// Tell the table how many items it has
table.setItemCount(10);
// Provide the callback handler--this handler
// is invoked when the table needs new rows
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem) event.item;
item.setText(items[table.indexOf(item)]);
TableItem item2 = (TableItem) event.item;
item2.setText("hm");
}
});