missing first column of a table [message #499859] |
Tue, 24 November 2009 07:10  |
Eclipse User |
|
|
|
Hi, I create table like in the snippet below and the first column of the table is missing. Any suggestions will be appreciated. Thanks.
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
/**
* Displays a table
*/
public class TableTest {
private boolean isPacked = false;
Table table = null;
public static void main(String[] args) {
new TableTest().run();
}
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
table = new Table(shell, SWT.BORDER | SWT.SINGLE | SWT.VIRTUAL);
for (int i = 0; i < 5; i++) {
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText("Column" + Integer.toString(i));
}
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.setItemCount(10);
table.addListener(SWT.SetData, new Listener () {
public void handleEvent (Event event) {
TableItem item = (TableItem) event.item;
int index = table.indexOf(item);
for (int j = 0; j < 5; j++) {
item.setText(j, "(" + index + "," + j + ")");
}
if (! isPacked) {
isPacked = true;
for (int i =0; i < table.getColumnCount(); i++) {
System.out.println("Pack column " + i);
table.getColumn(i).pack();
}
}
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05093 seconds