 <p>You need a reference to your instance of GUI1 in GUI2. So maybe add a private variable <code>private GUI1 firstGUI</code> in your GUI2 class. Then write a setter method <code>public void setGUI1(GUI1 myFirstGUI){ this.firstGUI = myFirstGUI; }</code>.</p> <p>Then you should set the GUI1 variable from the outside with this setter.</p> <p>And then you can call <code>firstGUI.dispose()</code> in your actionPerformed Method for btn2.</p>