日期:2014-05-20 浏览次数:20720 次
import java.awt.*; public class test extends Frame { public static void main(String []args) { Frame f=new Frame("我的窗口"); f.setVisible(true); } }
Frame f = new Frame("我的窗口"); f.setVisible(true); f.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } });
------解决方案--------------------
Frame f=new Frame("我的窗口");
f.setSize(new Dimension(100, 100));
f.setVisible(true);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
------解决方案--------------------
记得 import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
------解决方案--------------------
------解决方案--------------------
import javax.swing.*; import java.awt.*; public class Test { public static void main(String[] args) { JFrame myFrame = new JFrame("test"); // .......do whatever you are interest in myFrame.setSize(800,640); myFrame.setVisible(true); myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }