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 Android Security Essentials Live Lessons this week in the Android 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: 38107
    
  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: 10175
    
    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!]
 
Consider Paul's rocket mass heater.
 
subject: clear JPanel
 
Similar Threads
How to: clear the JPanel before repainting?
Setting the size of JComboBox
super.painComponent(g) not clearing my Jpanel
WA #2 ..... word association
Repeating JPanels