• 对话框


    //copyright©liupengcheng
    //http://www.cnblogs.com/liupengcheng

    addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });


    /**
    * Created by Administrator on 2014/11/4.
    */
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;

    class TestJDialog {
        public static void main(String [] args){
            JOptionPane.showMessageDialog(null,"程序开始启动");
            final JFrame f = new JFrame("TestJDialog");
            f.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

            f.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    int retval = JOptionPane.showConfirmDialog(f,"你真的要结束吗?"
                            ,"结束程序",JOptionPane.YES_NO_OPTION);
                    if (retval == JOptionPane.YES_OPTION)
                        System.exit(0);
                }
            });
            f.setSize(200,200);
            f.setVisible(true);
        }
    }

  • 相关阅读:
    wait与sleep区别?
    oracle死锁查询
    atomic 原子操作的类
    买票问题
    0001.第一个多线程demo--分批处理数据
    01: JavaScript实例
    01: 运维工作梳理
    04: 使用BeautifulSoup封装的xss过滤模块
    04: 打开tornado源码剖析处理过程
    03: 自定义异步非阻塞tornado框架
  • 原文地址:https://www.cnblogs.com/liupengcheng/p/4073238.html
Copyright © 2020-2023  润新知