This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes clear JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "clear JPanel" Watch "clear JPanel" New topic
Author

clear JPanel

Marc Beck
Ranch Hand

Joined: Sep 09, 2006
Posts: 36
How do I clear a JPanel?
I mean, I want to remove all its components without calling each of them individually.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37890
    
  22
Have you looked through the API specifications for JPanel to see whether there are any methods which remove all components?
Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 430
Just my two cents: Don't forget to invoke validate() on the JPanel to reflect changes when you remove all its components.


To be or not to be. It's a question.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Better make it revalidate() instead of validate() since its a JPanel


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
 
subject: clear JPanel
 
Similar Threads
How to: clear the JPanel before repainting?
WA #2 ..... word association
Repeating JPanels
super.painComponent(g) not clearing my Jpanel
Setting the size of JComboBox