wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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.

 
Consider Paul's rocket mass heater.
 
subject: how to prevent extra spaces in expand/collapse panel?
 
Similar Threads
problem while creating sliding panel
Collapsible Panel?
Expand/Collapse Panels
GUI advice appreciated
Collapsing Panels