How to interrupt Windows shutdown in a Swing application?

I have a Swing application, and I want to provide the user with a confirmation window before the application closes when Windows shuts down, and if the user selects "Cancel", the completion process should be interrupted.

I went through a couple of discussions on the forum, but could not get a specific answer. If someone successfully fulfilled this requirement, please help me do the same.

+3
source share
2 answers

This question discusses how to cancel Windows shutdown programmatically using the Win32 API and gives a very simple answer. Maybe ... all you have to do is write JNI / JNA code, and you can do the same with Java.

+2
source

add this line to the button event listener,

Runtime.getRuntime (). exec ("shutdown -a");

0
source

All Articles