• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

how to prevent extra spaces in expand/collapse panel?  RSS feed

 
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.
 
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.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!