日期:2014-05-20  浏览次数:20743 次

【菜鸟求问】JFrame 不能结束程序
代码1:
import javax.swing.JFrame;
public class FrameTest
{
        public static void main(String[] args)
        {
                JFrame frame = new JFrame("framedemo");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
        }
}

代码2:
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class FrameTest
{
        public static void main(String[] args)
        {
                JFrame frame = new JFrame("framedemo");
                frame.addWindowListener(new WindowAdapter()
                {
                        @Override
                        public void windowClosing(WindowEvent e)
                        {
                                System.exit(0);
                        }
                });
                frame.setVisible(true);

        }
}

运行这两个程序后,点 X 都不能结束程序,窗口都关不了,请问是什么问题啊?