import java.awt.*;
import java.awt.event.*;
public class WindowEvent
{
public static void main(String argv[])
{
Frame f=new Frame("window event text");
f.addWindowListener(new WindowEventHandler());
f.setSize(400,300);
f.setVisible(true);
}
}
class WindowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.out.println("window closing event");
System.exit(0);
}
}
为什么按了红叉仍然关不掉窗口?
import java.awt.event.*;
public class WindowEvent
{
public static void main(String argv[])
{
Frame f=new Frame("window event text");
f.addWindowListener(new WindowEventHandler());
f.setSize(400,300);
f.setVisible(true);
}
}
class WindowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.out.println("window closing event");
System.exit(0);
}
}
为什么按了红叉仍然关不掉窗口?
public void windowClosing(WindowEvent e)中WindowEvent 已经不再是你期望的WindowEvent 了,把名字改成WindowEvent123即可
把类名改了还是不行啊。
方法改了倒是可以(public void windowClosing(java.awt.event.WindowEvent e))!
知道为什么改名不行吗?
谢谢楼上的帮助啊!