File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes container components not removed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "container components not removed" Watch "container components not removed" New topic

container components not removed

C. Alan
Ranch Hand

Joined: Dec 17, 2004
Posts: 30
I have a class that extends JFrame, and uses contentPane to create a pane with various components. (I'm leaving out all of the fields to keep this brief)

Once the yes button is pushed, a new window is created using identical code, just with different components. That works perfectly. At the end of the sequence of four windows, there is an option to continue, or quit. The continue button just calls code I have placed above.

Last pane:

When it goes back to the original pane, I have artifacts left over. If I uncomment the c.validate, then the next window contains nothing but an empty box.

Since it goes through the four different versions of the window, why isn't it working when it goes back to the original window? I thought validate was the command to use after components have been added or removed in order to lay them out properly again?
[ January 25, 2005: Message edited by: C. Alan ]

<a href="" target="_blank" rel="nofollow">Malware Removal</a> - Get your system running like new again.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you could try revalidate()

or, I often find repaint() is required after validate()
C. Alan
Ranch Hand

Joined: Dec 17, 2004
Posts: 30
Thank you. Repaint worked perfetly.
I agree. Here's the link:
subject: container components not removed
It's not a secret anymore!