Exiting an Application When a Frame Is Closed
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) { System.exit(0); } }); } }