0

Is there any way to have a JOptionPane.showMessageDialog pop up when you end the program? I am wanting to display a log of users who have logged into my program during that specific run. I have the code completed for displaying the message, just am not sure as to how to get it to display when the program ends.

Thanks

javaGeek
  • 304
  • 1
  • 4
  • 11
  • how do you terminate your program ? click listener on close button ? – jmj Apr 09 '14 at 17:56
  • I don't have a close button on any of my frames (I have around 9 frames), they just simply press the "x" in the right hand corner of the frame. It would make sense to add a "close" click listener, but I feel it would make sense to add it on all 9 frame. – javaGeek Apr 09 '14 at 17:57
  • 1
    possible duplicate of [Popup for JFrame close button](http://stackoverflow.com/questions/15198549/popup-for-jframe-close-button) – Frakcool Apr 09 '14 at 17:59

1 Answers1

0

You can either add a listener to whatever event closes the application. You can use a WindowListener to detect when people click the X. Tutorial here: http://docs.oracle.com/javase/tutorial/uiswing/events/windowlistener.html

Or you can look into shutdown hooks.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107