Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-xxxfer.readnews.com!textspool1.readnews.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Daniele Futtorovic" Subject: Re: Setting uniform width Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 46 Date: Wed, 27 Apr 2011 15:42:45 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918965 96.60.20.240 (Wed, 27 Apr 2011 10:42:45 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:42:45 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:3066 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: ... I'd say I'd try to use a org.eclipse.jface.layout.TableColumnLayout: ...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: ...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