I have a simple GUI:
public class MyGUI extends JFrame{
public MyGUI(){
run();
}
void run(){
setSize(100,
Write this code within constructor of your JFrame:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.out.println("Uncomment following to open another window!");
//MainPage m = new MainPage();
//m.setVisible(true);
e.getWindow().dispose();
System.out.println("JFrame Closed!");
}
});