This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes how to prevent extra spaces in expand/collapse panel? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to prevent extra spaces in expand/collapse panel?" Watch "how to prevent extra spaces in expand/collapse panel?" New topic
Author

how to prevent extra spaces in expand/collapse panel?

laila NiHai
Ranch Hand

Joined: Oct 18, 2010
Posts: 35
Hello,

I am using the expandable/collapseble panel method found in this post:

http://www.coderanch.com/t/341737/GUI/java/Expand-Collapse-Panels

This works wonderfully; however, there is too much blank space at the bottom of the panel that I do not care for and only want the panel to resize enough to hold the expanded items and reduces as items are collapsed. I've tried different combination of Gridbaglayout constraints, but none seems to work properly. I will continue to try other ways... but thought maybe someone out there might know of a clever Java built-in way to do this.

Thank you in advance for your help.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
using Craig's code, change this (in main())

//f.setSize(360,500);
f.pack();

add the indicated line here


you will need to change main() so that 'f' is visible for mousepressed()

I did it this way, making f a class field, then changing main():
laila NiHai
Ranch Hand

Joined: Oct 18, 2010
Posts: 35
Michael - thank you soo much for your help. You've saved me from hours of trying to solve the issue... a simple solution like this makes me want to go bang my head against the wall.

Thanks again for your help.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to prevent extra spaces in expand/collapse panel?