This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Catching the window cross button in JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Catching the window cross button in JFrame" Watch "Catching the window cross button in JFrame" New topic
Author

Catching the window cross button in JFrame

sandeep dhingra
Ranch Hand

Joined: Jul 30, 2005
Posts: 41
What I want to do is catch when the user presses the cross button to close the application which is on a JFrame. Or disable this buton when there is some processing going on in some dialog box, So that the program does not end with unexpected results.
Please if anybody knows.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You'll have to add a WindowListener to your JFrame and code this in the windowClosing() method.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43935
    
  33
. . . or to disable the "x for exit" button on the JFrame use a different Default Close Operation. See the JFrame API.
 
Have you checked out Aspose?
 
subject: Catching the window cross button in JFrame
 
jQuery in Action, 3rd edition