本文共 667 字,大约阅读时间需要 2 分钟。
import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JFrame;import javax.swing.JOptionPane;public class JButtonTest extends JFrame{public static void main ( String[] args ){JButtonTest b = new JButtonTest ();b.addWindowListener (new WindowAdapter (){@Overridepublic void windowClosing ( WindowEvent e ){int exi = JOptionPane.showConfirmDialog (null, "确定不玩了么?", "友情提示", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);if (exi == JOptionPane.YES_OPTION){System.exit (0);}else{return;}}});b.setSize (300, 300);b.setLocationRelativeTo (null);b.setDefaultCloseOperation (JFrame.DO_NOTHING_ON_CLOSE);b.setVisible (true);}}
取消
评论
转载地址:http://afevo.baihongyu.com/