Re: Setting uniform width of a table
- From: Daniele Futtorovic <da.futt.newsLOVELYSPAM@xxxxxxxxxxx>
- Date: Fri, 25 Jan 2008 09:06:16 +0100
On 24.01.2008 19:22, Mark allegedly wrote:
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
By having a peek at the API docs:
<http://help.eclipse.org/stable/nftopic/org.eclipse.platform.doc.isv/reference/api/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/api/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/api/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/api/org/eclipse/jface/viewers/ColumnWeightData.html>
....but, in all honesty, that's just a guess.
DF.
.
- References:
- Setting uniform width of a table
- From: Mark
- Setting uniform width of a table
- Prev by Date: Re: Setting uniform width of a table
- Next by Date: Re: open another jframe
- Previous by thread: Re: Setting uniform width of a table
- Index(es):