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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top