Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GridBagLayout update without resize  RSS feed

 
Jeff Weinheimer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!