Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

container components not removed

 
C. Alan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try revalidate()

or, I often find repaint() is required after validate()
 
C. Alan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Repaint worked perfetly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic