File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Closing client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Closing client" Watch "Closing client" New topic

Closing client

Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
I am not sure how to handle this one. I have in my connection object, written code that releases all locks when a user exits the gui from the Exit item on my menu( I used the body of the close() method). However my frame uses DefaultCloseOperation and exits without releasing the locks.
I don't want to add a WindowListener and implement the same functionality which my controller handles in my view object. Please give me some advice on this one.
It is the fact that windowListener creates a WindowAdapter that is confusing. How do we seperate them into MVC pattern?
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
You could use the same WindowListener for both Exit JMenuItem and closing Action the JFrame
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
yes but how do I add the window listener to my controller and reference it from my view ?
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

reference it from my view ?

Why would your view need this information. Your controller should have a reference of your GUI, which hooks the WindowListener into GUI's action.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Closing client
It's not a secret anymore!