G'Day Everyone.

I was wondering whether someone can help me with my Java project. I have two interfaces, say: Interface1 and Interface2. On both interfaces, there is one JButton. When the Jbutton is clicked, the current window closes and the other one opens up and vice versa for the other inteface.

Shed some light on this please!

Usmaan

Each class must the other as global attribute. When a button is clicked call setVisible(false) method of the one you want to hide and setvisible(true) of the one you want to show. The above methods are methods of the JFrame class. You can also have the constructors so they can take each other as parameters.

class Frame1 extends JFrame {
    Frame2 fr2 = null;

    public Frame1() {
           ......
    }

   public void buttonClicked() {
       if (fr2==null) fr2 = new Frame2(this);
       setVisible(false);
       fr2.setVisible(true);
   }
}
class Frame2 extends JFrame {
   Frame fr1 = null;
   
   public Frame2(Frame fr1) {
        this.fr1 = fr1;
   }

   public void buttonClicked() {
       setVisible(false);
       fr1.setVisible(true);
   }
}

Thank you for the help javaAddict. I'm working on the Netbeans IDE. It's a pain, what with all the default code >.>

Many Thanks!