Bug (possibly only with xlib, but I doubt it): addNotify not always called for AWT components

Scott Gilbertson scottg@mantatest.com
Fri Jan 21 23:47:00 GMT 2005

I have narrowed down the problem in my earlier posting ("AWT app not working
with latest from cvs, seems to be CardLayout problem").  In my big
application, some components under a CardLayout were not being displayed.
The attached code illustrates the problem.

With my old gcc, which was "gcc (GCC) 3.5.0 20040603 (experimental)", on
linux/x86, the program works OK.  With a recent main branch checkout from
cvs, called "gcc (GCC) 4.0.0 20050108 (experimental)", I had to add the
addNotify call you'll see in there.  I'm using the xlib peers, but I suspect
the problem will occur with other peers as well.

I found that addNotify isn't called for components under the following
  - The component is lightweight AWT
  - The component is added to a container with a CardLayout
     (I'm not sure that it has to be CardLayout, but that's what my app was
  - The container has already been shown on-screen before this component is
That last one's the crux of the thing, I think.  It seems like in Container,
invalidateTree should clear the valid flag, but it doesn't, so validateTree
only works the first time it's called, and components added after that don't
get an addNotify call.  Since addNotify isn't called, the component's peer
is null, and isLightweight returns false, which essentially stops the
component from painting.

Would somebody familiar with the validateTree, invalidateTree and add
methods in Container be able to take a look?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CardLayoutTest.java
Type: application/octet-stream
Size: 5577 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20050121/7ff9f804/attachment.obj>

More information about the Java mailing list