Thomas Fritsch schrieb:
>> is there a way to force a JScrollPane to display a vertical scrollbar
>> only
[quoted text clipped - 5 lines]
>
> Thomas
Sorry, I meant
yourScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
Thomas
Babu Kalakrishnan - 01 Nov 2003 07:29 GMT
> Thomas Fritsch schrieb:
>
[quoted text clipped - 11 lines]
>
> yourScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
I think the first suggestion was the correct one. The
HorizontalScrollBarPolicy should be set to NEVER.
Some more points to remember are - a) Use an appropriate LayoutManager
for the panel that is inside the viewport, b) *Not* calling
setPreferredSize on this panel, c) Having the panel implement the
Scrollable interface and return "true" for the
getScrollableTracksViewportWidth method and "false" for
getScrollableTracksViewportHeight method.
Read the documentation of javax.swing.Scrollable and JScrollPane, as
well as the Java Tutorial chapter on How to use JScrollPane.
BK
Rene Ruppert - 03 Nov 2003 09:10 GMT
Hi Thomas,
yourScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_
NEEDED);
yourScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR
_AS_NEEDED);
sorry, but both won't work. Setting the scrollbar policies has no effect.
Setting horizontal to NEVER disables the scrolling completely without
leading to a wrapping of the content and setting vertical to AS_NEEDED won't
show a bar at all.
Anyway thanks.
cu
Rene
Babu Kalakrishnan - 04 Nov 2003 11:22 GMT
> yourScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_
> NEEDED);
[quoted text clipped - 8 lines]
>
> Anyway thanks.
Did you try implementing the Scrollable interface ? If not, try doing that.
Are you by any chance setting some hardcoded values to the preferredSize
parameter of the panel ? If you did so, remove that piece of code.
Difficult to guess further without seeing some code. I'm sure a lot of
people have used a JScrollPane in a zillion applications without having
a similar problem - which means you must be doing something wrong in
your code.
BK