title: How to set a JPanel to a different one
body: <p>I am working on a program using a JPanel to show a block of text,buttons,etc. and I am trying to set a JPanel equal to another one that i created but its not doing anything. Ignore my buttons and crap.</p>
  
  <p>I have the panel declared publicly </p>
  
  <pre><code>    public JPanel panel;
  </code></pre>
  
  <p>And Here is its stuff... </p>
  
  <pre><code>    panel = new JPanel();
      panel.setBackground(PanelColor);
      panel.setBounds(0, 93, 594, 478);
      contentPane.add(panel);
      panel.setLayout(null);
  </code></pre>
  
  <p>I want to make it so when i hit a button (in this case: btnKinematics) it changes a the panel to a different class i have called KinematicsPanel.java</p>
  
  <pre><code>    btnKinematics = new JButton("Kinematics");
      btnKinematics.setFont(ButtonFont);
      btnKinematics.setFocusPainted(false);
      btnKinematics.setBorder(compound);
      btnKinematics.setBackground(Color.WHITE);
      btnKinematics.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
  
              highlite(btnKinematics);
              panel = new KinematicsPanel();
              panel.setBackground(Color.WHITE);
          }
      });
      btnKinematics.setBounds(14, 60, 130, 23);
      contentPane.add(btnKinematics);
  </code></pre>
  
  <p>Thanks </p>
  
  <p>UPDATE: FIXED</p>
  
  <p>I made some changes and this worked</p>
  
  <pre><code>    contentPane.remove(panel);
      contentPane.add(new KinematicsPanel());
      contentPane.repaint();
  </code></pre>
  
  <p>thanks</p>