Events

Tom Kelliher, CS 116

Nov. 10, 2000

Administrivia

Announcements

Won't cover all of readings in class. Example: switch.

Quiz at end of class.

Comment on the PostLab assignment: enter one record at a time.

Assignment

Read Chapter 6, Lab 6 handout.

From Last Time

FrontPage 2000 and your CS ToolBox.

Outline

  1. Events.

  2. Delegation model.

  3. Events exercise.

Coming Up

Lab 6.

Events

Sect. 6.2. Examples:

  1. Button pushes.

  2. Mouse motion, clicks.

  3. Key presses.

  4. Etc.

Delegation Model

Sect. 6.3.

Components delegate event handling to other objects (including themselves --- this).

  1. Import the event handling package:
    import java.awt.event.*;
    

  2. A Component (source) generates events.

  3. A listener object (listener) handles events:
    1. Corresponding class implements XXXXListener interface.

    2. All interface methods must be implemented. Sects. 6.1, 6.4.

    3. Need code in the listener class interface methods to deal with the event.

  4. source delegates listener to handle events:
    source.addXXXXListener(listener);
    

Events Exercise

Study the Etch-A-Sketch applet, adding buttons to move the ball up and down.



Thomas P. Kelliher
Thu Nov 9 18:24:17 EST 2000
Tom Kelliher