Re: JScrollPane content sizing
- From: Daniele Futtorovic <da.futt.news@xxxxxxxxxxxxxxx>
- Date: Sat, 24 May 2008 04:04:20 +0200
On 2008-05-23 13:17 +0100, John allegedly wrote:
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.
That is indeed the answer the OP needed, AFAICT.
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.
Then set the minimum size.
You may set this up dynamically by subclassing the JViewPort's
getPreferredSize() and getMinimumSize() (and maybe getMaximumSize()) and
modifying the returned java.awt.Dimension Object to have its width field
match the desired value.
This might not be the most elegant solution, but it should work and has
the advantage being appliable to all (proper) LayoutManagers.
PS: please do not top-post.
--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
.
- References:
- JScrollPane content sizing
- From: MRe
- Re: JScrollPane content sizing
- From: John
- Re: JScrollPane content sizing
- From: Andrew Thompson
- Re: JScrollPane content sizing
- From: MRe
- Re: JScrollPane content sizing
- From: John
- JScrollPane content sizing
- Prev by Date: Re: JScrollPane content sizing
- Next by Date: Re: Painting Negative
- Previous by thread: Re: JScrollPane content sizing
- Next by thread: Re: JScrollPane content sizing
- Index(es):
Relevant Pages
|