Basic HTML version of Foils prepared 13 October 97

Foil 43 Separate Classes for Event Listeners

From Java Tutorial, July 1, 1996 CSC499(JSU) CPS406/606 -- Fall Semester 97. by Nancy J. McCracken,Geoffrey C. Fox


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 Wed Apr 1 1998