Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to prevent extra spaces in expand/collapse panel?

 
laila NiHai
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic