这个程序有两个问题 一是为窗口f添加监听器有错误,二是无法关闭窗口,求解释 谢谢帮忙
importjava.awt.Color;importjava.awt.Frame;importjava.awt.event.WindowAdapter;importja...
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class FirstFrame extends Frame{
FirstFrame(String string){
super(string);
}
public static void main(String args[]){
FirstFrame f=new FirstFrame("the first one");
f.setSize(300,200);
f.setBackground(Color.black);
f.setVisible(true);
f.addWindowListenner(f.new windowadapter());
}
class mywindowadapter extends WindowAdapter
{
public void windowClosing(WindowEvent we){
System.exit(0);
}
}
} 展开
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class FirstFrame extends Frame{
FirstFrame(String string){
super(string);
}
public static void main(String args[]){
FirstFrame f=new FirstFrame("the first one");
f.setSize(300,200);
f.setBackground(Color.black);
f.setVisible(true);
f.addWindowListenner(f.new windowadapter());
}
class mywindowadapter extends WindowAdapter
{
public void windowClosing(WindowEvent we){
System.exit(0);
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询