title: How to refresh a JPanel at runtime?
body: <p>I have found that there are many similar topics here, but my problem is something more complicated.</p>
  
  <p>Background of my problem:- </p>
  
  <p>I have a JFrame called Main. On this JFrame I have two buttons and one JPanel called WorkingPanel. Then I have another JPanel(called PlayerPanel) but this one is a seprate file (as a class).</p>
  
  <p>Now I want that when I click a button, it should change WorkingPanel to PlayerPanel. I have wrote following code.</p>
  
  <pre><code>private void MenuButtonPlayerViewMouseClicked(java.awt.event.MouseEvent evt) {
      // TODO add your handling code here:
      WorkingPanel = new PlayerPanel();
      System.out.println(WorkingPanel.getName());
      WorkingPanel.revalidate();
      WorkingPanel.repaint();
  
      WorkingPanel.setVisible(true);
  
      Window.revalidate();
      Window.repaint();
  }    
  </code></pre>
  
  <p>Please guide me, Thanks.</p>