From: Erik V. <ev...@us...> - 2008-11-27 22:20:26
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4564/rails/ui/swing Modified Files: StatusWindow.java Log Message: Added confirmation question on closing StatusWindow Index: StatusWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StatusWindow.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** StatusWindow.java 30 Jun 2008 20:35:29 -0000 1.23 --- StatusWindow.java 27 Nov 2008 22:20:21 -0000 1.24 *************** *** 24,28 **** */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, ActionPerformer { private static final long serialVersionUID = 1L; --- 24,28 ---- */ public class StatusWindow extends JFrame implements ActionListener, ! KeyListener, /*WindowListener,*/ ActionPerformer { private static final long serialVersionUID = 1L; *************** *** 210,214 **** setJMenuBar(menuBar); ! } public StatusWindow() { --- 210,215 ---- setJMenuBar(menuBar); ! ! } public StatusWindow() { *************** *** 263,266 **** --- 264,280 ---- addKeyListener(this); + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE ); + final JFrame frame = this; + addWindowListener(new WindowAdapter () { + public void windowClosing(WindowEvent e) { + if (JOptionPane.showConfirmDialog(frame, "Do you really want to exit the game?", "Select", JOptionPane.OK_CANCEL_OPTION) + == JOptionPane.OK_OPTION) { + frame.dispose(); + System.exit(0); + } + } + }); + + pack(); } *************** *** 623,625 **** --- 637,641 ---- public void keyTyped(KeyEvent e) {} + + } |