Java tutorial
import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class Main { public static void main() { Frame frame = new Frame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { Frame frame = (Frame) evt.getSource(); frame.setVisible(false); // frame.dispose(); } }); } }