File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 36478
    
  16
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: 425
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: 9990
    
    7

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!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clear JPanel
 
Similar Threads
Repeating JPanels
Setting the size of JComboBox
WA #2 ..... word association
super.painComponent(g) not clearing my Jpanel
How to: clear the JPanel before repainting?