title: Call method from a panel at another class(the method) that terminats current panel
body: <p>i have three classes {<code>FirstFrame, Login, Register</code>} ... there is a method in <code>FirstFrame</code> to change between <code>Logi</code> and <code>Register</code></p>
  
  <p><code>FirstFrame</code> code :</p>
  
  <pre><code>public class FirstFrame extends javax.swing.JFrame {
  
  public FirstFrame() {
      initComponents();
      setLayout(new BorderLayout());
      changeTo(Login.class);        
  }
  
  public void changeTo(Class&lt;?&gt; c){
      getContentPane().removeAll();
      try {
          Object obj = c.newInstance();
          getContentPane().add((Component) obj);
          pack();
          setVisible(true);
          System.out.println("here");
      } catch (InstantiationException ex) {
          Logger.getLogger(FirstFrame.class.getName()).log(Level.SEVERE, null, ex);
      } catch (IllegalAccessException ex) {
          Logger.getLogger(FirstFrame.class.getName()).log(Level.SEVERE, null, ex);
      }
  
  }
  }
  </code></pre>
  
  <p>In <code>Register</code> I have a button that stores data then go back to <code>Login</code>(supposedly)</p>
  
  <p>It works great if I call from any button inside <code>FirstFrame</code></p>
  
  <p>The question here is how do I call <code>changeTo(Class&lt;?&gt; c)</code> from inside <code>Register</code>?</p>