import java.awt.Frame; import java.awt.Button; import java.awt.event.WindowListener; import java.awt.event.WindowEvent; class Program01 extends Frame { Button button1 = new Button("Klikk"); Program01() { addWindowListener(new WindowListener() { public void windowClosing(WindowEvent e) { System.exit(0); } public void windowDeactivated(WindowEvent e){} public void windowActivated(WindowEvent e){} public void windowDeiconified(WindowEvent e){} public void windowIconified(WindowEvent e){} public void windowClosed(WindowEvent e){} public void windowOpened(WindowEvent e){} }); add(button1); pack(); setVisible(true); } public static void main(String args[]) { new Program01(); } }