JAVA之GUI编程窗体事件

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);
}
}

posted @ 2014-07-16 22:36  塔斯曼  阅读(299)  评论(0编辑  收藏  举报