title: java Access parent method from imported child class
body: <p>Am a java newbie. Learning from the web. I am stuck with an issue with my code.
  I have three class. mainclass.java, oneclass.java, twoclass.java.
  I imported oneclass and twoclass in mainclass.</p>
  
  <p>oneclass has a "next" button. What i want to do is onActionEvent on next btn , call a function from mainclass, which would set the visibility of oneclass to false and twoclass to true.
  Am posting the whole code for 
  mainclass.java</p>
  
  <pre><code>    package com.mainclass;
      import com.twoframe.twojframes;
      import com.secondframe.secondjframe;
  
  public class MainClass {
      private static com.secondframe.twoclass panel2;
      private static com.twoframe.oneclass panel1;
  
  
      private static void openPanel1(){
        panel1 = new com.twoframe.oneclass();
        panel1.setVisible(true);
      }
      public static void toggleVisibility(){
          System.out.println("called from child");
          panel2 = new com.secondframe.twoclass();
          panel2.setVisible(true);
          panel1.setVisible(false);
      }
      public static void main(String args[]) {
          java.awt.EventQueue.invokeLater(new Runnable() {
              public void run() {
                  openPanel1();
              }
          });
  
      }
  }
  </code></pre>
  
  <p>oneclass.java</p>
  
  <pre><code>jButton1.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  jButton1ActionPerformed(evt);
              }
          });
       private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
          {                                         
              // TODO add your handling code here:
             //Basically something like -- mainclass.toggleVisibility();
  
          } 
  </code></pre>
  
  <p>Thank you.</p>