
package com.deveshcodelab.examples.swt;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class SWTSnippet16 extends Composite {
public SWTSnippet16(Composite parent) {
super(parent, SWT.NONE);
setLayout(new FillLayout(SWT.VERTICAL));
Table tree = new Table(this, SWT.BORDER | SWT.SINGLE| SWT.FULL_SELECTION);
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
TableColumn column = new TableColumn(tree, SWT.SINGLE| SWT.BORDER);
column.setText("Column 1");
column.pack();
column = new TableColumn(tree, SWT.SINGLE| SWT.BORDER);
column.setText("Column 2");
column.pack();
for (int i = 1; i < 10; i++) {
TableItem treeItem = new TableItem(tree, SWT.SINGLE);
treeItem.setText(0,"column 1 item "+i);
treeItem.setText(1,"column 2 item "+i);
}
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
Composite composite = new SWTSnippet16(shell);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}