- import java.awt.*;
- import java.awt.event.*;
- class AwtDemo
- {
- public static void main(String[] args)
- {
- Frame f = new Frame("my awt");
- f.setSize(300,160);
- f.setLocation(300,200);
- f.setLayout(new FlowLayout());
-
- Button b = new Button("Who are you");
- f.add(b);
- f.setVisible(true);
-
- f.addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e){
- System.out.println("window closed");
- System.exit(0);
- }
- public void windowActivated(WindowEvent e){
- System.out.println("Activated window");
- }
- public void windowOpened(WindowEvent e){
- System.out.println("aaaaaa,to be opened");
- }
- });
- }
- }
复制代码 问
public void windowOpened(WindowEvent e){
System.out.println("aaaaaa,to be opened");
}
这句为何没有执行,而且有的时候,一运行,第二句,有时候没出现 Activated window
试了几次搞不懂了,求解? |