开发者

How to abort Windows shutdown in a Swing application?

开发者 https://www.devze.com 2022-12-17 17:05 出处:网络
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 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");

0

精彩评论

暂无评论...
验证码 换一张
取 消