//copyright©liupengcheng
//http://www.cnblogs.com/liupengcheng
/**
* 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);
}
}