Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3552

Re: JScrollPane content s

From "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this>
Subject Re: JScrollPane content s
Message-ID <g17str$re0$1@registered.motzarella.org> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:45 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
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"

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | Next | Find similar | Unroll thread


Thread

Re: JScrollPane content s "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000

csiph-web