Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Listeners in controller class  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
My ambition is to put all listeners in a ClientController class but I can�t see how to do it.
Normally I would have the listener as an inner class like this:
public class ClientView{
xxxxx
button.addMouseListener(new SearchListener());
xxxxx
class SearchListener extends MouseInputAdapter{
public void mouseClicked(MouseEvent me){
button.setEnabled(false);
}
}
}
How can I put all listeners in the ClientController and how should the controller get access to the "button" ??? Does anybody have a good example??
//Cecilia
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your code, move the SearchListener to the controller from the view class and call setSearchListener(new SearchListener()) defined in the view from the controller constructor.
 
Cecilia Anderson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm...still don�t get it
Should I put the SearchListener class as an inner class in the ClientController?? And if I do...
what should I add to button.addMouseListener(??)

Could you give an example??
 
ranger
Sheriff
Posts: 17314
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, in your GUI class, the view you have a method like such.
fileExit is a MenuItem

Then in your Controller to hook into the GUI so that it can run a method when an action occurs you have the following code.
frontEnd is the reference to the instance of the GUI class that the controller has.

Hope that helps
Mark
[ May 10, 2002: Message edited by: Mark Spritzler ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!