日期:2014-05-20 浏览次数:20676 次
import java.awt.*; import java.awt.event.*; public class TestWindowClose { public static void main (String[] args) { } } class MyFrame extends Frame{ MyFrame(String s){ super(s); setLayout(null); setBounds(300,300,400,300); this.setBackground(new Color(204,204,255)); setVisible(true); this.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e){ setVisible(false); System.exit(-1); } } ); } }
import java.awt.*; import java.awt.event.*; public class TestWindowClose { public static void main (String[] args) { String s = null; MyFrame myFrame=new MyFrame(s); } } class MyFrame extends Frame{ MyFrame(String s){ super(s); setLayout(null); setBounds(300,300,400,300); this.setBackground(new Color(204,204,255)); setVisible(true); this.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e){ setVisible(false); System.exit(-1); } } ); } }