Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Closing client

 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use the same WindowListener for both Exit JMenuItem and closing Action the JFrame
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes but how do I add the window listener to my controller and reference it from my view ?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic