vinee
vinee

Reputation: 39

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 couple 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.

Upvotes: 3

Views: 1324

Answers (2)

professionalcoder2010
professionalcoder2010

Reputation: 367

add this line in the event listener of button,

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

Upvotes: 0

Stephen C
Stephen C

Reputation: 718836

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.

Upvotes: 2

Related Questions