package GUI;
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class studyFrame {
public static void main(String[] args) {
Frame f=new Frame();
f.setTitle("WINDOW----BY VON");
f.setSize(500,400);
f.setLocation(300,200);
f.setVisible(true);
f.setLayout(new FlowLayout());
f.addWindowListener(new MyWin());
Button b=new Button("I am a button");
f.add(b);
}
//public void windowClosing(WindowEvent e){
// System.exit(0);
//}
}
class MyWin extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
原文地址:http://www.cnblogs.com/vonk/p/3849875.html