SWT TableColumn.pack doesn't make columns wider [message #326400] |
Tue, 18 March 2008 15:02  |
Eclipse User |
|
|
|
I am running on Windows XP Professional 2002 Service Pack 2.
I have an SWT table that is populated by a TableViewer. The table has one
column. After the contents of the column is updated, the code calls
TableColumn.pack to resize the column so the entire text of the item
appears in the column. The first time the column is packed everything
works mostly ok. The column size is a bit too short to accommodate the
entire text of the longest item. (I would like to know how to fix this one
but my other problem is more pressing.)
However, when a new wider item is added to the top of the table where a
narrower item used to be, pack doesn't make the column any wider. The
column stays the same width. I tried adding a header and double clicking
on the header would only make the column smaller. It would not increase
the width.
I stepped into the TableColumn.pack method and saw that when it went to
Windows to get the width of the new item, it returned the narrower width
of the item that used to be there.
It seems as if the underlying windows GUI widget still thinks it has the
old text. Is there any method that I can call before pack to refresh the
widths of the underlying windows GUI widgets before I call pack.
Here's the code to create the table and viewers.
/*
* Table for editing this path.
*/
Table pathTable;
/*
* Viewer that populate the path table.
*/
TableViewer pathTableViewer;
/*
* Column containing directories in the path.
*/
TableColumn dirColumn;
pathTable = toolkit.createTable(tableComp, SWT.SINGLE);
pathTable.setLinesVisible(true);
pathTableViewer = new TableViewer(pathTable);
pathTableViewer.setContentProvider(new
ResolvedPathContentProvider(resolver));
pathTableViewer.setLabelProvider(new LabelProvider());
dirColumn = new TableColumn(pathTable,SWT.LEFT);
dirColumn.setText("Directory");
dirColumn.setResizable(true);
Thanks very much for your help!
Carolyn
|
|
|
|
Powered by
FUDForum. Page generated in 0.03008 seconds