Board index » jbuilder » Re: Setting column titles in JTable, TableDialogEditDemo example

Re: Setting column titles in JTable, TableDialogEditDemo example


2005-01-08 04:30:16 AM
jbuilder22
Sounds like this bug :-
bugs.sun.com/bugdatabase/view_bug.do
I played with your code and setting the header preferred size as per the
work-around seems to fix the problem. I didn't get the caveat at the end.
Arth
"Richard M. Ulrich" < XXXX@XXXXX.COM >wrote in message
Quote
"John McGrath [TeamB]" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>I cannot reproduce this. The table's AutoResizeMode property is set to
>AUTO_RESIZE_NEXT_COLUMN, which means that the table will always be the
>same width as the scroll pane's viewport. As a result, the horizontal
>scrollbar is never shown, so I cannot scroll to the right. Can you give
>me steps to reproduce the problem you are seeing?

Sorry, we had changed the property to AUTO_RESIZE_NEXT_COLUMN to generate
the last figure of the doc, and forgot to switch it back. Change
AutoResizeMode to to "OFF" in order to see the problem behavior.

Thanks,

R

 
 

Re:Re: Setting column titles in JTable, TableDialogEditDemo example

Arthur,
Quote
Sounds like this bug :-

bugs.sun.com/bugdatabase/view_bug.do

I think it is EXACTLY that bug! I wonder why it is that a bug this
important, reported in version 1.3 back in 2001, hasn't been fixed yet!
We've wasted a LOT of time.
Quote
I played with your code and setting the header preferred size as per the
work-around seems to fix the problem. I didn't get the caveat at the end.
Thanks, we'll give it a try.
Richard
 

Re:Re: Setting column titles in JTable, TableDialogEditDemo example

On 1/7/2005 at 3:30:16 PM, Arthur Ore wrote:
Quote
Sounds like this bug :-

bugs.sun.com/bugdatabase/view_bug.do
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:
www.JPMcGrath.net/newsgroups/e-mail.html
 

{smallsort}

Re:Re: Setting column titles in JTable, TableDialogEditDemo example

"John McGrath [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
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.
John,
Setting the preferred width of each column is a much better solution! It
seems to work fine.
Thanks,
Richard