本帖最后由 feigecal 于 2012-7-15 14:58 编辑
import java.awt.*;
import java.awt.event.*;
class AwtDemo
{
public static void main(String[] args)
{
Frame f=new Frame();
f.setSize(500,400);
f.setLocation(200,100);
//f.setBounds(200,200,500,400);
f.setLayout(new FlowLayout());
f.setVisible(true);
Button b=new Button("anNiu");
f.add(b);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.out.println("挂掉");
System.exit(0);
}
public void windowActivated(WindowEvent e)
{
System.out.println("激活");
}
public void windowOpened(WindowEvent e)
{
System.out.println("打开");为什么我运行时这里没有打印出“打开”这两个字呢?
}
});
}
} |
|