Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Shutdown Hook  RSS feed

 
Manjunatha N.S.
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Swing Application how to handle ShutDown operation for eg. like displaying Dialog box with modified files before existing SwingApplication.

I tried with Runtime.addShutDownHook() it is not possible display the Dialog Box, as AWT Thread is also in Shut Down Process. I Observed in NetBeansIDE my requirement is working fine.

Can any one knows about it or how it is implemented in NetBeans.

thanx in advance
Manju
 
sander hautvast
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should be easy
show the dialog in the windowlistener before System.exit() is invoked.
 
Manjunatha N.S.
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
winowListener is called in Normal Exit, but if you do end Task of your application in TaskManager, how to handle this scenario.

This is done NetBeans3.6 IDE, if do some modification and end task of NetBeansIDE Dialog box asks for saving.

any Idea how it is done NetBeans

thanks
Manju
 
Petr Blahos
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manjunatha,

Now, what exactly are you talking about? I have run netbeans 3.6 in
Windows XP, and when I killed both processes runide in the taskmanager,
netbeans just disappeared without a wink.

Or are you talking about Unix window manager close command? Then
it really would be:

as Sander has posted.

Best regards,
Petr
 
Manjunatha N.S.
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,

On Windows, if you have NetBeans and you done some modfication to file in Netbeans Editor & in Windows Task Manager "Application" Tab select NetBeans 3.6 and end task then it will ask user to save before existing.

May be what you have done is in Windows Task Manager under "Processes" tab if you kill runide.exe, this is wonot ask user to save, this case documented in Runtime.addShutdownHook().

what i wanted know how it works in the 1st case I mentioned.

Hope it is clear.

thanks
Manjunatha



 
Petr Blahos
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right. Indeed I did End Process on processes tab. This "End Process"
on Applications tab is equivalent to pressing the little cross on
the top-right of the window and therefore my previous post applies.
I've just tried following and it worked.


P.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!