Re: JScrollPane content sizing



The Scrollable interface is what you are looking for. If you override the "getScrollableTracksViewportWidth()" method for your JPanel, and make it return true. The consequence is that the JPanel will have the size of the JViewport width.

I have a question myself, which is related to the thread:

I have a JList in a JViewport, in a JScrollPane.

I want the opposite: the JScrollPane width should be the preferred width of the JList, but i don't manage to do it. The JViewport has the preferred size of the JList, but it's actual wdith is smaller.

Help apreciated :)

MRe a écrit :
Hi,

Thanks for the responses.

I can't really give example code, as I don't know where to begin..
What I've done so far has been mostly reading tutorials and API
documents - any code I've written has done nothing like I want it
(it's all new to me), so I wouldn't know what's a demonstrationable
version of what I want (it'd probably just make my sketchy problem
description more confusing). I'll continue to hack through; if I
still can't figure it out maybe I'll draw a picture to explain..

Thanks again,
Kind regards,
Eliott
.



Relevant Pages