• Post Reply Bookmark Topic Watch Topic
  • New Topic

action performed method for ALT+CTRL+DEL  RSS feed

 
Mukesh Sheoran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method from the windowListner will be called if we closed the application using ALT+CTRL+DELETE
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ALT+CTRL+DEL closes your application???!!!
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are talking about system exit due to Ctrl+C or some other events like system shutdown, I would recommend taking a look at
 
Mukesh Sheoran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, actually, I want to do some action like clearing the resource Monitor fields when application is closed using ALT+CTRL+DEL. So I want to know what actionlistner can be used when user is closing the application with this shortcut.
Can Somebody please help me out???
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the resources are application global and should be disposed no matter what, then you can use shutdownhooks.
But note that in some rare cases like native call crash, the method may not call.
But in any case, this is the best shot you got.

You simly need to pass a Thread as an argument to the above method.
When the system shuts your thread will be run. So basically you need to do your operations inside the that thread's run method.
 
Rob Spoor
Sheriff
Posts: 21050
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shutdown hooks will not be called if the JVM crashes, or is forcefully terminated. The latter is the difference between Task Manager's "Applications" tab, which sends close signals and the application tries to close nicely, and the "Processes" tab, which sends a termination signal and the application does not close nicely. The latter will bypass shutdown hooks.
 
Mukesh Sheoran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is looking quite convincing. One last question : when or from where should I invoke this method. Suppose I am using an application with lots of Forms classes. In one the form classes, I am doing this ALT+CTRL+DEL.. Should I use this Runtime.getRuntime.addShutdownHook() in the form activate method or I will need to have some kind of actionListener for this ? Please Reply
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ususally shutdown hooks are added at the entry point of the application or just before creating your resource(which you want to dispose in shutdown). If you have lot of distributed resources intialized distributedly then maybe you should add the hook at the entry point or when the first resource is initialized
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!