Program import java.awt.*; import java.awt.event.*; public class awtexample extends Frame{ public static void main(String[] args) { Frame f= new Frame("New Frame"); f.setSize(400, 500); f.setVisible(true); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { System.exit(0); } }); } } Output