• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clear JPanel

 
Marc Beck
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I clear a JPanel?
I mean, I want to remove all its components without calling each of them individually.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49812
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked through the API specifications for JPanel to see whether there are any methods which remove all components?
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just my two cents: Don't forget to invoke validate() on the JPanel to reflect changes when you remove all its components.
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better make it revalidate() instead of validate() since its a JPanel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic