Basic HTML version of Foils prepared 19 July 97

Foil 28 How to Write an Event Listener

From Overview of JDK Version 1.1 Extensions CPS616 -- Information Track of CPS -- Spring Semester 97. by Nancy J. McCracken

JDK1.1 Events for Foil 28
Two ways: write the event listener class, implementing all method names or
Subclass an adapter class. For each interface that has more than one method, java.awt.event provides an adapter class. This is a class that implements the interface by implementing all method names with an empty body (ignoring event). If you wish to only handle some event types and not others, you can subclass the adapter class and override only those methods used in your application.
Then your code (applet or application) will create an instance of your event listener class and register it with the event source by calling the addXListener method of the component generating the event.



© 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 Sun Nov 29 1998