Article View: borland.public.jbuilder.java.swing
Article #658Re: Setting column titles in JTable, TableDialogEditDemo example
From: John McGrath [TeamB]
Date: Sat, 08 Jan 2005 05:29
Date: Sat, 08 Jan 2005 05:29
40 lines
3208 bytes
3208 bytes
On 1/7/2005 at 3:30:16 PM, Arthur Ore wrote:
> Sounds like this bug :-
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4473075
That does seem to describe the problem with the header, which is certainly
rather strange. However, it does not deal with the column resize problem.
I think the problem there is that it really does not make sense to specify
a preferred size for a JTable with AutoResizeMode set to OFF. The JTable
is placed inside the JViewport of a JScrollPane. The JViewPort will
always try to accommodate the preferred size of the component that it
contains, so when it is validated, it sets the table to its preferred
size. And when its size is set, the JTable will distribute the columns so
as to fit within
its width.
When you try to resize a column and AutoResizeMode is OFF, that causes the
table size to change, which results in a revalidation. Again, the
viewport will set the table to its preferred size and the table will fit
the columns to that size. So AutoResizeMode=OFF pretty much requires that
the table be allowed to set its own preferred width.
What I do not understand is, what is the point of setting the preferred
size of the JTable? If this is designed to control the initial width of
the columns, that is really not the way to do it. Instead, you can set
the preferred width of the individual columns, and the JTable will
determine its own preferred width based on that. And then, when the user
resizes a column, the preferred width will change as well, so the viewport
will not change the size back to its old preferred size.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<xn0dwzwku7gu3k900p@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.wiretrip.org!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41a8c0a1@newsgroups.borland.com> <41ab0304@newsgroups.borland.com> <xn0dqe27g17u5no001@newsgroups.borland.com> <41ae3fd6$1@newsgroups.borland.com> <xn0dqic152q8rpn001@newsgroups.borland.com> <41af6646$1@newsgroups.borland.com> <41b60985@newsgroups.borland.com> <41dc80b9@newsgroups.borland.com> <xn0dwxxgt5qojdz00h@newsgroups.borland.com> <41de9366$1@newsgroups.borland.com> <41def15b$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,2ec5ccf013472ede X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit From: "John McGrath [TeamB]" <ng-b@JPMcGrath.net> Subject: Re: Setting column titles in JTable, TableDialogEditDemo example Newsgroups: borland.public.jbuilder.java.swing References: <41a8c0a1@newsgroups.borland.com> <41ab0304@newsgroups.borland.com> <xn0dqe27g17u5no001@newsgroups.borland.com> <41ae3fd6$1@newsgroups.borland.com> <xn0dqic152q8rpn001@newsgroups.borland.com> <41af6646$1@newsgroups.borland.com> <41b60985@newsgroups.borland.com> <41dc80b9@newsgroups.borland.com> <xn0dwxxgt5qojdz00h@newsgroups.borland.com> <41de9366$1@newsgroups.borland.com> <41def15b$1@newsgroups.borland.com> User-Agent: XanaNews/1.17.1.2 Message-ID: <xn0dwzwku7gu3k900p@newsgroups.borland.com> X-Ref: newsgroups.borland.com ~XNS:000000F7 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 NNTP-Posting-Host: 141.158.234.226 Date: 7 Jan 2005 21:29:58 -0800 X-Trace: newsgroups.borland.com 1105162198 141.158.234.226 (7 Jan 2005 21:29:58 -0800) Lines: 40 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.wiretrip.org!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail