为什么main函数跑完了,程序没结束?
import java.awt.*;
import java.awt.event.*;
public class Form extends WindowAdapter
{
Frame f;
public void display()
{
f = new Frame("Form");
f.setSize(200,200);
f.setLocation(200,140);
f.setBackground(Color.lightGray);
f.addWindowListener(new WinClose());
f.setVisible(true);
System.out.println("display is over");
}
public static void main(String[] args)
{
(new Form()).display();
System.out.println("main is over"); //为什么main函数跑完了,程序没结束?
}
}class WinClose extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
import java.awt.*;
import java.awt.event.*;
public class Form extends WindowAdapter
{
Frame f;
public void display()
{
f = new Frame("Form");
f.setSize(200,200);
f.setLocation(200,140);
f.setBackground(Color.lightGray);
f.addWindowListener(new WinClose());
f.setVisible(true);
System.out.println("display is over");
}
public static void main(String[] args)
{
(new Form()).display();
System.out.println("main is over"); //为什么main函数跑完了,程序没结束?
}
}class WinClose extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货