Basic HTML version of Foils prepared 19 July 97

Foil 23 Event Model in Java 1.1

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


Based on concept of "event listener":
  • An event listener is any object which wants to receive events.
  • An event source is an object which generates events. An event source will keep a list of event listeners who want to be notified for particular events.
  • The event source notifies event listeners by invoking a particular method in the event listener and passing it an event object, which has all the information about the event.
  • Example: a component with a button is an event source. Formerly, a button click was reported to the action method of the component. The button click event is now called ActionEvent. You must write a class which implements ActionListener (which can be local to the component) and which provides a method called actionPerformed(). This method will receive the event object and take appropriate action.



© 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