title: Java AWT: Clean / Remove a container panel
body: <p>Java AWT: Clean / Remove a container panel</p>
  
  <p>I am new to Java AWT, and I'm wanting to do an exercise for college.</p>
  
  <p>This would be the code:</p>
  
  <pre><code>public class Panel0 extends JPanel {
  
       //...     
  
       private void createMyLayout(bool test) {
  
  
           this.add(BorderLayout.CENTER, new Panel1(test));
  
       }
  
       //...
  }
  
  
  public class Panel1 extends JPanel {
  
      public Panel1(bool test){
  
          super(new GridLayout(1,4));
  
          if(breed!= Breed.ZOMBIE) 
              add(new Panel2("helow 1 test"));
          else
              add(new Panel2("helow 2 test"));
  
      }
  
  }
  
  public class Panel2 extends JPanel{
  
        public Panel2(String myText){
            super(new BorderLayout());
            add(new JLabel(myText));
         }    
  }
  </code></pre>
  
  <p>When you call the method "createMyLayout" I need to delete the previous layout and recreate it with new data, but do not get it done.</p>
  
  <p>Thanks.</p>