• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

GridBagLayout update without resize

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In gridBagLayout, components are adjusted according to their weights when the container is resized.
I have a situation where I need the container to be updated with new weights without resizing the container.
can this be done?
Do I have to send a resize message to the container?
If so, how is this done?
TIA,
Jeff
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use container.validate(). In some cases you may find it necessary to first call layoutManager.invalidateLayout(container). I'm not sure when exactly this is necessary, so try it both ways to see if there's a difference.
 
Jeff Weinheimer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried container.validate() on the panel containing the GridBagLayout. Even after performing GridBagLayout.invalidateLayout(Container) no update occurs until the page is resized.
I think that spacing and weighting is only updated upon a resize
event; an invalidation of the container doesn't seem to be enough.
Any further ideas?
Jeff Weinheimer
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very strange. You could also try container.repaint() to see if that gives any better results. What JDK are you using? If it's an older one, perhaps it's a bug that has been fixed in one of the newer releases. Note that JDK 1.3 just got its official release for Windows a few days ago, so it's probably worth trying that if you're using Windows. Even if it doesn't solve your immediate problem, it will probably be useful to have it at some point. Beyond that, I have no idea what the problem is. Good luck.
 
Jeff Weinheimer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ended up finding a work around. I found a different layout manager called proportionLayout(www.helplets.com) which gives me the desired results.
Thanks for your help.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We had this problem and we resized the container by one pixel.
 
Jeff Weinheimer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing under Linux with the JDK 1.2-pre-release 2.
There appears to be a problem with the JDK because the program did not experience the same problems when compiled and run on another machine.
The commercial version of JDK 1.2.2 is now available for Linux. I should try it.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic