I have an application that uses a JFrame. I have also used jframe.setDefaultCloseOperation(EXIT_ON_CLOSE) to handle the closing of the JFrame using the windows "X" button available on most OS's. However, what I want to happen is, if that "X" button on the title bar is click, i have to update a field in database with some additional information. Right now that update only happens when the user uses the "EXIT" button that I have provided them. Is there a way to call some method when the "X" on the windows title bar is clicked in order to make this update before the application closes? I suppose I could just not enable that function but that doesn't make for a very flexible solution and end users will hate that that have to use the EXIT button that I created.
Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Hi Ryan, Try adding a WindowListener to your JFrame instead. You can extend the WindowAdapter class and put your code in the (overridden) windowClosing() method followed by a System.exit(0). Hope this helps Michael Morris SCJP
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Joined: Jun 28, 2000
That should do it...should I make that and anonymous inner class like ActionListener?