Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to disable close window

 
saravanan rajendran
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I hardly searching how to disable close window please help me i have below code how to use that code in servlet.If i integrated that code into servlet it will work fine? please ya help me i will follow in that

CODE:
=====

myDialog.setDefaultCloseOperation(
WindowConstants.DO_NOTHING_ON_CLOSE);
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets do not have Java GUIs, so the Swing code you posted is not applicable to them.

What kind of window are you talking about - a browser window? If so, note that that is a user-hostile thing to do. If the user wishes to close a window then a well-behaved application should not stop him from doing so.

What are you trying to accomplish?
[ July 23, 2008: Message edited by: Ulf Dittmer ]
 
Joe Harry
Ranch Hand
Posts: 10122
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets run from within a browser and if you call a Swing GUI from within your servlet, then you can only control the Swing part of it.

But if you intend to disable the cloase button of the browser, then you have to try some Java scripts to do it.
 
saravanan rajendran
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi thanks for your reply i feel very difficult to do that.please help me actually i have crmpopup window using servlet it contain logout button. without pressing logout button they simply closed window means very problem database value wont change. for that i need to know how to disable close window button in crmpopup screen please give some idea if you know good link to get code please tell

thank you
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a "crmpopup screen"? Is this a browser popup?

Could you not add an HttpSessionListener to perform the clean up code when the session is timed out?


But if you intend to disable the cloase button of the browser, then you have to try some Java scripts to do it.

It is not possible to catch all the various ways a browser window could be closed. For example, if a browser is process is killed any client side JavaScript can't run. Its not really worth the effort. As Ulf has already said, preventing the user using their browser exactly as they want to is not something its wise to do. You'll drive them up the wall.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic