Problem with Container validate() method
I have a question reqarding AWT in JDK 1.5.0_05-b05 on Windows XP.
In my very simple AWT GUI, I have a frame, which is a container of several labels and a button. The button has an action listener associated with it. The frame and its objects are initially displayed correctly. The button click and window close events behave as expected.
The problem arises in two distinctive situations:
- when this frame is deiconified from the iconified state in the tool bar,
- when the frame is moved past the screen borders and back to the screen's displayable area again.
In each situation, it looks like the frame's layout manager (GridBagLayout) adds multiple groups of their objects infinitely - the labels and the button appear over and over again, as they would have been added in a loop. It all ends in the following exception that is thrown by thevalidate() method called on the parent container.
Exception in thread"AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 512
Thevalidate() method is called after all object are added to the container (in the implementedpaint() method).
The stack trace at the time of exception is as follows:
at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:879)
at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:816)
at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:1412)
at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1372)
at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:712)
at java.awt.Container.layout(Container.java:1401)
at java.awt.Container.doLayout(Container.java:1390)
at java.awt.Container.validateTree(Container.java:1473)
at java.awt.Container.validate(Container.java:1448)
at drd.gui.AboutWindow.paint(Gui.java:639)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
at java.awt.Component.dispatchEventImpl(Component.java:4031)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Does anybody have a hint why this happens and how to solve the problem?
Thanks in advance.
Regards,
Bostjan

