• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to prevent extra spaces in expand/collapse panel?

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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

https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic