title: Java - CardLayout show() IllegalArgumentException
body: <p>I have a problem with the CardLayout show method </p>
  
  <p>So I declare my CardLayout and apply it to my JPanel</p>
  
  <pre><code>CardLayout cl = new CardLayout();
  panel.setLayout(cl);
  </code></pre>
  
  <p>Then I add a 2 panels into the CardLayout</p>
  
  <pre><code>cl.addLayoutComponent(panel, "menuScreen");
  cl.addLayoutComponent(panel1, "gameScreen");
  </code></pre>
  
  <p>I then have a JButton that when is clicked, I show the gameScreen</p>
  
  <pre><code>public void mouseClicked(MouseEvent e) {
      if(e.getSource() ==  (startGame))
  
      scenechange.show(panel,"gameScreen");
  }
  </code></pre>
  
  <p>The only problem is that it doesn't go to my gameScreen. It gives me an llegalArgumentException.
  It says "Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: wrong parent for CardLayout".</p>
  
  <p>Thanks in advance</p>