buoy.event

Class EventSource

Known Direct 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(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.

Constructor Details

EventSource

public EventSource()
Create a new EventSource.

Method Details

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.
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(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.
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.

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.
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.

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.
Parameters:
eventType - the event class or interface which should no longer be sent
target - the object which was receiving the events

Written by Peter Eastman.