buoy.event
Class EventSource

java.lang.Object
  extended by buoy.event.EventSource
Direct Known Subclasses:
RadioButtonGroup, Widget

public class EventSource
extends java.lang.Object

An EventSource is any object that can dispatch events. It maintains a list of "event links", which are methods to be called when specific types of events occur.

EventSource is the superclass of Widget, and the vast majority of EventSources are Widgets.

Author:
Peter Eastman

Constructor Summary
EventSource()
          Create a new EventSource.
 
Method Summary
 void addEventLink(java.lang.Class eventType, java.lang.Object target)
          Create an event link from this object.
 void addEventLink(java.lang.Class eventType, java.lang.Object target, java.lang.reflect.Method method)
          Create an event link from this object.
 void addEventLink(java.lang.Class eventType, java.lang.Object target, java.lang.String method)
          Create an event link from this object.
 void dispatchEvent(java.lang.Object event)
          Send out an object representing an event to every appropriate event link that has been added to this object.
 void removeEventLink(java.lang.Class eventType, java.lang.Object target)
          Remove an event link so that an object will no longer be notified of events of a particular type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventSource

public EventSource()
Create a new EventSource.

Method Detail

addEventLink

public void addEventLink(java.lang.Class eventType,
                         java.lang.Object target)
Create an event link from this object. The target object must have a method called processEvent(), which either takes no arguments, or takes an object of class eventType (or any of its superclasses or interfaces) as its only argument. When events of the desired class (or any of its subclasses) are generated by this object, that method will be called.

Parameters:
eventType - the event class or interface which the target method wants to receive
target - the object to send the events to

addEventLink

public void addEventLink(java.lang.Class eventType,
                         java.lang.Object target,
                         java.lang.String method)
Create an event link from this object. When events of the desired class (or any of its subclasses) are generated by this object, the specified method will be called on the target object.

Parameters:
eventType - the event class or interface which the target method wants to receive
target - the object to send the events to
method - the name of the method to invoke on the target object. The method must either take no arguments, or take an object of class eventType (or any of its superclasses or interfaces) as its only argument.

addEventLink

public void addEventLink(java.lang.Class eventType,
                         java.lang.Object target,
                         java.lang.reflect.Method method)
Create an event link from this object. When events of the desired class (or any of its subclasses) are generated by this object, the specified method will be called on the target object.

Parameters:
eventType - the event class or interface which the target method wants to receive
target - the object to send the events to
method - the method to invoke on the target object. The method must either take no arguments, or take an object of class eventType (or any of its superclasses or interfaces) as its only argument.

removeEventLink

public void removeEventLink(java.lang.Class eventType,
                            java.lang.Object target)
Remove an event link so that an object will no longer be notified of events of a particular type.

Parameters:
eventType - the event class or interface which should no longer be sent
target - the object which was receiving the events

dispatchEvent

public void dispatchEvent(java.lang.Object event)
Send out an object representing an event to every appropriate event link that has been added to this object.



Written by Peter Eastman.