CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Events

Events
Handle events
Java event model

What happens when a button is pressed

What happens when any event occurs

The Java event model

  • GUI applications depend on events that represent user interactions such as clicking a button or selecting an item from a list.
  • All events are represented by an event object that derives from the EventObject class. The event object contains information about the event that occurred.
  • An event listener is an object that responds to an event.
  • The class that defines an event listener must implement an event listener interface.
  • A component that generates an event is called an event source.
  • To respond to an event, an application must register an event listener object with the event source that generates the event.
  • The class for the event source provides a method for registering event listeners. Then, when the event occurs, the event source creates an event object and passes it to the event listener.
Previous | Java event model | Two types | Structure event handling | Panel | Separate class | Inner class | Separate event listeners | Anonymous inner classes | Next