java匿名类关闭窗口
import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class Window1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Frame f1=new Frame(); f1.setSize(100,100); Button b1=new Button(); f1.add(b1); f1.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); f1.setVisible(true); } }