title: Java CardLayout Show Problem
body: <p>Ok me again i need help. For some reason when i click a button the button dissapears but not the panel</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  
  public class MainMenu extends JPanel implements ActionListener{
  
  ImageDirectory ID = new ImageDirectory();
  PlayMenu PM = new PlayMenu();
  JButton Play;
  CardLayout CL;
  Image BG;
  
      public MainMenu(){
  
      CL = new CardLayout(180,220);
      setLayout(CL);
      Play = new JButton("play");
      Play.addActionListener(this);
      ImageIcon BGSource = new ImageIcon(ID.Background);
      BG = BGSource.getImage();
      add(Play, "Play");
      add(PM, "PMenu");
      }
  
      public void actionPerformed(ActionEvent e){
  
          if(e.getSource() == Play){
  
              CL.show(this, "PMenu");
              }
          }
  
          public void paintComponent(Graphics g){
  
              g.drawImage(BG,0,0,500,500,this);
              }
   }
  </code></pre>
  
  <p>Here is the class that i tried to show when button is clicked:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  
  public class PlayMenu extends JPanel{
  
  public PlayMenu() {}
  
  
  }
  </code></pre>