title: Change contentpane of Frame after button clicked
body: <p>I want to be able to set a JFrame's contentpane after a button inside one of that frame's JPanels has been clicked.</p>
  
  <p>My architecture consists of a controller which creates the JFrame and the first JPanel inside of it. From within the first JPanel I'm calling a method: setcontentpane(JPanel jpanel) on the controller. However, instead of loading the passed JPanel it does nothing but removing all Panels (see code below)</p>
  
  <p>ActionListener inside of the first JPanel:</p>
  
  <pre><code>public void actionPerformed(ActionEvent arg0) {
              controller.setpanel(new CustomPanel(string1, string2));
          }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>JFrame frame;
  
  public void setpanel(JPanel panel)
  {
      frame.getContentPane().removeAll();
      frame.getContentPane().add(panel);
      frame.repaint();
  }
  
  public Controller(JFrame frame)
  {
      this.frame=frame;
  }
  </code></pre>
  
  <p>Can anyone tell me what I'm doing wrong? Thanks :)</p>