Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3066

Re: Setting uniform width

From "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this>
Subject Re: Setting uniform width
Message-ID <fnc58p$n8b$2@aioe.org> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:42 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
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.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread


Thread

Re: Setting uniform width "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000

csiph-web