Here's my snippet:
/*
* Created on Jan 24, 2005 by Robin Wilson
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
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 TableColumnProblemExample {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Table Column Pack");
GridLayout vertical = new GridLayout();
vertical.numColumns = 1;
shell.setLayout(vertical);
final Table table = new Table(shell, SWT.SINGLE);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final TableColumn col1 = new TableColumn(table,SWT.CENTER);
col1.setText("Column 1");
final TableColumn col2 = new TableColumn(table,SWT.CENTER);
col2.setText("Column 2");
col1.pack();
col2.pack();
Button button = new Button(shell, SWT.PUSH);
button.setText("Fill Data");
button.addSelectionListener( new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
//table.layout(true);
table.setRedraw(false);
table.removeAll();
String [] data1 = { "1", "2" };
String [] data2 = { "3", "4" };
TableItem item1 = new TableItem(table, SWT.NONE);
item1.setText( data1 );
TableItem item2 = new TableItem(table, SWT.NONE);
item2.setText( data2 );
col1.pack();
col2.pack();
shell.pack();
table.setRedraw(true);
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Steve Northover wrote:
1) Which platform?
2) Post a stand alone snippet that shows the problem.
"Robin Wilson" <robinwilson@xxxxxxx> wrote in message
news:cstmik$116$1@xxxxxxxxxxxxxxxxxx
The first time I create my table and pack all the columns it looks
great.
After, I change the contents and call pack on each column again the