Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: JVertical scrollbar enabled in JTable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JVertical scrollbar enabled in JTable



Steve Roy wrote:

>Strangely, if you add code to add 1 line to the table, then the scrollbar
>will become disabled as it should be. But what I need is to find out how to
>force the scrollpane to disable the vertical scrollbar since the table is
>empty.

That behavior sounds like a bug.

I'm guessing, but it might be related to preferred-size, which I think is
how the scroll-pane decides whether to enable and/or show scrollbars.
Assuming it is, and further assuming that it's some edge condition like 0
or -1 that's causing the scroll-pane to misbehave, try giving the table a
small positive preferred-size value, like 10,10 or even 1,1.

If that solves the problem when the table is empty, you'll have to smarten
it up to return that value ONLY when the table is empty, otherwise return
the real preferred-size.  Overriding a JTable method should work.

If none of that works, you might have to look around in the source for
JTable or JScrollPane and find exactly what condition is triggering the
enabled-scrollbar on empty.  Once you know that, you may be able to
override a method in a subclass to fix the misbehavior.  If not, filing a
bug and/or doing a hack may be needed.

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.