title: Reference a jPanel component from a separate class
body: <p>Getting to good grips with Java programming and made a simple game.</p>
  
  <p>I want to make a GUI for it with contains two different 'screens'
  The best way I have found to swap screens is to use CardLayout.</p>
  
  <p>So, I have a container panel which contains both IntroPanel or GamePanel.</p>
  
  <p>By doing </p>
  
  <pre><code>contPanel.setLayout(cl);
              contPanel.add(introPanel, "1");
              contPanel.add(gamePanel, "2");
              cl.show(contPanel, "1");
  </code></pre>
  
  <p>I can change the show value from 1 to 2 and it changes the panel that's showing.</p>
  
  <p>That works fine, my question is:
  How can I reference a jButton1 that is on the introPanel?
  I want to add an event handler on a jButton but from within this class (so I can swap the panels)</p>
  
  <p>Thanks,</p>
  
  <p>Mike</p>
  
  <p>Code: </p>
  
  <pre><code>    public static void main(String[] args) {    
      boolean playAgain = true;
  
      SwingUtilities.invokeLater(new Runnable() {
          public void run() {
              JFrame GUI = new JFrame();
  
              GUI.setVisible(true);
              GUI.setSize(500, 500);
              GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              CardLayout cl = new CardLayout();
  
              // Different Panels //
              JPanel contPanel = new JPanel();
              JPanel introPanel = new IntroPanel();
              JPanel gamePanel = new GamePanel();
                              introPanel.jLabel1.getText();
  
              // Card layout //
              contPanel.setLayout(cl);
              contPanel.add(introPanel, "1");
              contPanel.add(gamePanel, "2");
              cl.show(contPanel, "1");
              GUI.add(contPanel);
          }
      });
  </code></pre>