How to abort Windows shutdown in a Swing application?
I have a Swing application and I want to present a confirmation box to user before the application is closed on windows shutdown and if the user selects cancel, the shutdown process should abort.
I went through co开发者_StackOverflow中文版uple of discussions in the forum but couldn't get a concrete answer. If anybody has successfully implemented this requirement, please guide me for implementing the same.
This question discusses how to cancel a Windows shutdown programatically using the Win32 API, and gives a really simple answer. Maybe ... all you need to do is to write some JNI / JNA code and you can do the same thing from Java.
add this line in the event listener of button,
Runtime.getRuntime().exec("shutdown -a");
精彩评论