import java.awt.*;
public class windowshow extends Frame{
public windowshow(){
}
public boolean handleEvent(Event event)
if(event.id==Event.WINDOW_DESTROY)
{
System.exit(0);
}
return super.handleEvent(event);
}
public static void main(String args[]){
Frame window=new Frame();
window.setTitle("MENU");
window.resize(400,300);
window.setResizable(true);
window.show();
}
}
为什么点窗口右上角的X不能关闭窗口????
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});
楼上的写法是对的,这里为匿名内部类的写法,就是出理点击
窗体上的叉关闭的。将代码直接放在main()里就行了。