JavaBean Events   «Prev  Next»
Lesson 4 Event sources
ObjectiveLearn how event sources are used to facilitate event communication.

Event Sources Communication

An event source is a component capable of generating events. Event source must provide a means of registering listeners, which is how the sources know where to send event notifications. When an event occurs within an event source, the source is responsible for examining the registered listeners and sending event notifications appropriately.

Java Components that support 1) low-level and 2) semantic event listener interfaces

Similar to event listeners, event sources can be distinguished by whether they generate low-level or semantic events. Following are the standard Java components that generate low-level events, and therefore support low-level event listener interfaces:
  1. Component
  2. Dialog
  3. Frame

Following are the standard Java components that support semantic event listener interfaces:
  1. Button
  2. Choice
  3. Checkbox
  4. CheckboxMenuItem
  5. List
  6. MenuItem
  7. Scrollbar
  8. TextField


Definition: Event source: a component capable of generating events.

JavaBeans Event Model

  1. Based the Java 1.1 event model
  2. An object interested in receiving events is an event listener – sometimes called event receiver
  3. An object that generates (fire) events is called an event source – sometimes called event sender
  4. Event listeners register their interest of receiving events to the event source
    Event source provides the methods for event listeners to call for registration
  5. The event source maintains a list of listeners and invoke them when an event occurs

In the next lesson, you learn how to handle events by registering event listeners.