Article View: borland.public.jbuilder.java.swing
Article #7633How do you REALLY set column widths in a table?
From: Steve Swett
Date: Wed, 10 Jan 2001 09:57
Date: Wed, 10 Jan 2001 09:57
23 lines
1649 bytes
1649 bytes
The following code at the "How to Use Tables" section of the on-line Java
Tutorial doesn't work for me:
TableColumn column = null;
for (int i = 0; i < 5; i++) {
column = table.getColumnModel().getColumn(i);
if (i == 2) {
column.setPreferredWidth(100); //sport column is bigger
} else {
column.setPreferredWidth(50);
}
}
It won't even compile because it complains about the
"column.setPreferredWidth(100)" statement as if it was a bad method. If you
let Jbuilder prompt for you, after you key "column." it won't list the
setPreferredWidth method.
My table is a simple one and doesn't use a model. Does it need to?
Can someone give me a simple example of setting column widths for a 2-column
table where the first column is twice the width of the second column?
Thanks.
Technical Details
Message-ID:
<3a5c3183_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!news.tele.dk!194.213.69.151!news.algonet.se!algonet!neel.uni2.net!newssuck.uni2.dk!bornews.borland.com!dnews!199.176.229.81Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,72d904887cb9b6b9,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2001-01-10 02:09:01 PST From: "Steve Swett" <swett@ncats.net> Newsgroups: borland.public.jbuilder.java.swing Subject: How do you REALLY set column widths in a table? Date: Wed, 10 Jan 2001 04:57:11 -0500 Lines: 26 X-Newsreader: Microsoft Outlook Express 4.72.3155.0 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 NNTP-Posting-Host: 199.176.229.81 Message-ID: <3a5c3183_2@dnews> X-Trace: 10 Jan 2001 01:55:15 -0800, 199.176.229.81 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.cs.utwente.nl!newshunter!cosy.sbg.ac.at!news.tele.dk!194.213.69.151!news.algonet.se!algonet!neel.uni2.net!newssuck.uni2.dk!bornews.borland.com!dnews!199.176.229.81