错哪了,关于关闭java图形化窗口小程序

importjava.awt.*;importjava.awt.event.*;publicclassMyFrame{publicstaticvoidmain(Strin... import java.awt.*;
import java.awt.event.*;
public class MyFrame
{ public static void main(String args[])
{

Frame f=new Frame("mybole");
f.setSize(600,400);
f.setLocation(100,100);
f.setBackground(Color.blue);
//f.setLayout(new BorderLayout(10,10));
//f.setLayout(new FlowLayout(FlowLayout.LEFT));
f.setLayout(new GridLayout(3,2,10,10));
Button btn1=new Button("sunxin");
Button btn2=new Button("weixin");
Button btn3=new Button("WEST");
Button btn4=new Button("EAST");
Button btn5=new Button("CENTER");
f.add(btn1,"North");
f.add(btn2,"South");
f.add(btn3,"West");
f.add(btn4,"East");
f.add(btn5,"Center");
f.addWindowListener(new MywindowListener());
f.show();

}
class MywindowListener implements WindowListener
{
public void WindowOpened(WindowEvent e)
{

}
public void WindowClosing(WindowEvent e)
{
System.exit(0);
}
public void WindowClosed(WindowEvent e)
{

}
public void WindowIconified(WindowEvent e)
{

}
public void WindowDeiconified(WindowEvent e)
{

}
public void WindowActivated(WindowEvent e)
{

}
public void WindowDeactivated(WindowEvent e)
{

}
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub

}
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub

}
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub

}
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub

}
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub

}
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub

}
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub

}
}
}
哪里有错啊,请高手指点
展开
 我来答
白木道人
2009-12-17 · TA获得超过1299个赞
知道小有建树答主
回答量:767
采纳率:0%
帮助的人:520万
展开全部
import java.awt.*;
import java.awt.event.*;

public class MyFrame {
public static void main(String args[]) {

Frame f = new Frame("mybole");
f.setSize(600, 400);
f.setLocation(100, 100);
f.setBackground(Color.blue);
f.setLayout(new GridLayout(3, 2, 10, 10));
Button btn1 = new Button("sunxin");
Button btn2 = new Button("weixin");
Button btn3 = new Button("WEST");
Button btn4 = new Button("EAST");
Button btn5 = new Button("CENTER");
f.add(btn1, "North");
f.add(btn2, "South");
f.add(btn3, "West");
f.add(btn4, "East");
f.add(btn5, "Center");
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}

});
f.setVisible(true);

}
}
705434
2009-12-16 · TA获得超过112个赞
知道小有建树答主
回答量:110
采纳率:0%
帮助的人:124万
展开全部
直接写个内部类就好了,还写这么麻烦~
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
灬心十个朋味
2009-12-28
知道答主
回答量:4
采纳率:0%
帮助的人:0
展开全部
其实你要关闭窗口可以直接写一条语句就可以了
那就是:this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式