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