Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2008

Tip: Looking for answers? Try searching our database.

Setting uniform width of a table

Thread view: 
Mark - 24 Jan 2008 18:22 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.