This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to disable close window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to disable close window" Watch "how to disable close window" New topic
Author

how to disable close window

saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
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
Marshal

Joined: Mar 22, 2005
Posts: 41049
    
  43
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 ]

Ping & DNS - my free Android networking tools app
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9344
    
    2

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.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
Don't get me started about those stupid light bulbs.
 
subject: how to disable close window
 
Similar Threads
this function disable close window
Java Help popup
disable close button
How to Disable Close Button
Popup window close button