欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

当窗体关闭时退出程序的示例,窗体退出示例,package cn.o

来源: javaer 分享于  点击 26120 次 点评:213

当窗体关闭时退出程序的示例,窗体退出示例,package cn.o


package cn.outofmemory.snippets.desktop;import java.awt.Frame;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;public class FrameCloseEventListener {  public static void main(String[] args) {      // Create the frame      Frame frame = new Frame();      // Add a listener for the close event      frame.addWindowListener(new WindowAdapter() {          public void windowClosing(WindowEvent evt) {              // Exit the application              System.exit(0);          }      });      // Display the frame      int frameWidth = 300;      int frameHeight = 300;      frame.setSize(frameWidth, frameHeight);      frame.setVisible(true);  }}
相关栏目:

用户点评