buoy.event
Class EventSource
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.
void | addEventLink(Class eventType, Object target) - Create an event link from this object.
|
void | addEventLink(Class eventType, Object target, Method method) - Create an event link from this object.
|
void | addEventLink(Class eventType, Object target, String method) - Create an event link from this object.
|
void | dispatchEvent(Object event) - Send out an object representing an event to every appropriate event link that has been added to this object.
|
void | removeEventLink(Class eventType, Object target) - Remove an event link so that an object will no longer be notified of events of a particular type.
|
EventSource
public EventSource()
Create a new EventSource.
addEventLink
public void addEventLink(Class eventType,
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.
eventType
- the event class or interface which the target method wants to receivetarget
- the object to send the events to
addEventLink
public void addEventLink(Class eventType,
Object target,
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.
eventType
- the event class or interface which the target method wants to receivetarget
- the object to send the events tomethod
- 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(Class eventType,
Object target,
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.
eventType
- the event class or interface which the target method wants to receivetarget
- the object to send the events tomethod
- 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.
dispatchEvent
public void dispatchEvent(Object event)
Send out an object representing an event to every appropriate event link that has been added to this object.
removeEventLink
public void removeEventLink(Class eventType,
Object target)
Remove an event link so that an object will no longer be notified of events of a particular type.
eventType
- the event class or interface which should no longer be senttarget
- the object which was receiving the events
Written by Peter Eastman.