日期:2014-05-20 浏览次数:20734 次
import java.awt.event.*; import java.awt.*; class TestStopWatch extends Frame { public TestStopWatch() { addWindowListener(new WindowAdapter() { public void WindowClosing(WindowEvent e) { dispose(); System.exit(0); } }); } public static void main(String []args) { TestStopWatch sw=new TestStopWatch(); sw.setSize(400,400); sw.setVisible(true); } }
import java.awt.*; import javax.swing.*; import java.awt.event.*; public class ButtonDir{ public static void main(String args[]){ JFrame f = new JFrame("测试"); f.setSize(500,400); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//关闭 } }
------解决方案--------------------
用JFrame吧,不要用AWT了
一个语句就能搞掂了