Basic HTML version of Foils prepared Sept 21 1998

Foil 43 Separate Classes for Event Listeners

From Java Tutorial 98- 3: Graphics and the Abstract Windowing Toolkit NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken


In designing classes for event handling, typically there is a class that defines the components where the response to the event is supposed to be performed. It is the most straightforward to make this class implement the listener for those events.
In large applications, some Java experts recommend that it is a better design to always make the event listener class a separate class. They find that they can make event listener classes generic enough so that they can reuse a class such as
  • public class ActionHandler implements ActionListener
  • to handle ActionEvents for many parts of the application.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998