title: Java swing difference remove and removeAll
body: <p>What is de difference between remove and removeAll in the java swing library?
  I have one control panel and a panel which can be changed with the control panel.
  This changing is done in the parent frame object.
  When I use the code:</p>
  
  <pre><code>public void showNextPanel(){
          if(hasNextPanel()){
              getSelectedPanel().setVisible(false);
              getContentPane().removeAll();
              getContentPane().add(controlPanel);
              selectedPanel++;
              getContentPane().add(getSelectedPanel());
              getSelectedPanel().setVisible(true);
              revalidate();
              repaint();
          }else{
              System.exit(0);
          }
      }
  </code></pre>
  
  <p>Then everything works exactly as expected. When I change the removeAll in the remove statement, this selected panel becomes gray, but still visible. When resizing my frame, the new frame is visible, you can see it is hiding behind the previous selected panel. Then my code is:</p>
  
  <pre><code>public void showNextPanel(){
          if(hasNextPanel()){
              getSelectedPanel().setVisible(false);
              getContentPane().remove(getSelectedPanel());
              selectedPanel++;
              getContentPane().add(getSelectedPanel());
              getSelectedPanel().setVisible(true);
              revalidate();
              repaint();
          }else{
              System.exit(0);
          }
      }
  </code></pre>
  
  <p>Why does my JPanel disappear when using removeAll but not when using remove?</p>