本帖最后由 love风之吻浩 于 2012-1-9 19:24 编辑
我在eclipse下运行一下一段代码(仅是核心代码):
Frame f1=new Frame("my awt");
f1.setVisible(true);
f1.setLayout(new FlowLayout());
f1.setSize(500,300);
f1.setLocation(300,200);
Button b1=new Button("我是一个按钮");
f1.add(b1);
f1.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.out.println("我关");
System.exit(0);
}
public void windowActivated(WindowEvent e)
{
System.out.println("我活了");
}
public void windowDeactivated(WindowEvent e)
{
System.out.println("我不被调用了");
}
public void windowOpened(WindowEvent e)
{
System.out.println("我被打开了");
}
public void windowStateChanged(WindowEvent e)
{
System.out.println("我变");
}
});
却发现运行程序时windowOpened(WindowEvent e)方法没调用,换句话说就是控制台没输出“我被打开了”字样,请问诸位何解?还有windowStatechanged(windowevent e)方法怎么使它被调用,因为我改变窗口大小,并不触发此方法,即控制台没有输出“我变”字样,求高人指点? |