• 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: 17309
11
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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!