Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Resizing JPanel within JScrollPane

Thread view: 
McMatt - 22 Feb 2007 18:37 GMT
Hello,

how can the size of a JPanel automatically be calculated?

The panel which is scrollable in the scrollpane has always the height
which I set with setPreferredSize(Dimension). If the components on
that panel need less place it should be smaller so that the scroll
bars can disappear if not necessary. And if the components on that
panel need more space it should be larger so that one can see all of
the stuff when scrolling down.

I hope the description is exact enough.

Thanks for any help in advance.

Matthias
Andrew Thompson - 22 Feb 2007 18:49 GMT
..
> how can the size of a JPanel automatically be calculated?

Try..
 panel.validate();
 // then do nothing with preferred size..

..if that fails to do what's needed, I
suggest you prepare an SSCCE of the code.
<http://www.physci.org/codes/sscce>

Andrew T.
McMatt - 23 Feb 2007 19:17 GMT
Hello,

thanks for the quick reply. During the preparation of a SSCCE it
turned out that more elements are involved in it than expected.

The main reason was a layout in on of the components.

But I needed still a validate() call - namely scrollPane.validate().

Thanks for your help,
Kind regards,

Matthias

> ..
>
[quoted text clipped - 9 lines]
>
> Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.