import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Java窗体事件 {
public static void main(String[] args) {
Frame f = new Frame("WindowEvent");
f.setSize(400,300);
f.setLocation(300, 200);
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent e) {
System.out.println("windowOpened---窗体打开事件");
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("windowActivated---窗体激活事件");
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("windowClosed---窗体关闭事件");
}
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("windowClosing---窗体正在关闭事件");
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("windowDeactivated---窗体停用事件");
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("windowDeiconified---窗体取消图标化事件");
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("windowiconified---窗体图标化事件");
}
});
}
}