I'm baffled as to how to set column widths to be a size I want (using
SWT/Jface).
My code is basically this:
tv = new TableViewer(parent,SWT.FULL_SELECTION);
-snip-
table = tv.getTable();
-snip-
tc1 = new TableColumn(table,SWT.CENTER);
tc1.setText("Col 1");
tc1.setWidth(150);
tc2 = new TableColumn(table,SWT.CENTER);
tc2.setText("Col 2");
tc2.setWidth(150);
-snip-
But the setWidth(150) seems to be ignored (on my RHEL4 box), and the
table appears with its own idea of what the widths should be (which is
not uniform). I've seen the use of setWidth() in other sample Java
code, and I've set mine up the same way, but it doesn't work. What am I
doing wrong? The bottom line is that I want all my columns in the table
to be same width, so maybe setWidth() is not the ideal way of
accomplishing this...
Your thoughts?
Mark
Roedy Green - 24 Jan 2008 18:52 GMT
>But the setWidth(150) seems to be ignored (on my RHEL4 box),
There are 3 width-setting methods, min, max and preferred.

Signature
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com
Mark - 24 Jan 2008 19:58 GMT
While true with Swing, this does not apply using SWT/JFace. Thanks,
though. Does anyone else have any clues how this can be done?
Mark
>> But the setWidth(150) seems to be ignored (on my RHEL4 box),
>
> There are 3 width-setting methods, min, max and preferred.
Mark - 24 Jan 2008 19:59 GMT
While true with Swing, this does not apply using SWT/JFace. Thanks,
though. Does anyone else have any clues how this can be done?
Mark
>> But the setWidth(150) seems to be ignored (on my RHEL4 box),
>
> There are 3 width-setting methods, min, max and preferred.
Roedy Green - 24 Jan 2008 18:53 GMT
>But the setWidth(150) seems to be ignored (on my RHEL4 box),
see http://mindprod.com/jgloss/jtable.html

Signature
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com
Daniele Futtorovic - 25 Jan 2008 08:06 GMT
> I'm baffled as to how to set column widths to be a size I want (using
> SWT/Jface).
[quoted text clipped - 18 lines]
>
> Mark
By having a peek at the API docs:
<http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/ap
i/index.html>
... I'd say I'd try to use a org.eclipse.jface.layout.TableColumnLayout:
<http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/ap
i/org/eclipse/jface/layout/TableColumnLayout.html>
...that class's setColumnData(Widget, ColumnLayoutData) method:
http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/ap
i/org/eclipse/jface/layout/TableColumnLayout.html
#setColumnData(org.eclipse.swt.widgets.Widget,%20org.eclipse.jface.viewers.ColumnLayoutData)
...with, say, an appropriately configured instance of ColumnWeightData:
<http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/ap
i/org/eclipse/jface/viewers/ColumnWeightData.html>
...but, in all honesty, that's just a guess.
DF.