import javax.swing.*; import java.awt.*; import java.awt.event.*; public class FrameClose { public static void main(String[] args) { // Create an empty frame and show it. Do not // register any window listener, instead let the // default close operation // happen when the frame is beeing closed. JFrame f = new JFrame(); //Set the default close operation to EXIT_ON_CLOSE, which //will terminate the virtual machine. f.setDefaultCloseOperation( f.EXIT_ON_CLOSE ); // Display the example . . . f.setSize(150, 80); f.setVisible(true); } }