ADK CVS

tryllian.util.event
Interface EventCallback

All Superinterfaces:
java.io.Serializable

public interface EventCallback
extends java.io.Serializable

Interface meant to translate generic callbacks to specific method calls. It is a workaround for not having method pointers in Java (o dear!).

Example

Suppose you have the following listener interface:
  interface MyListener extends java.util.EventListener {
 
      void myEventOccured(MyEvent event) { ... }
  }
    
You can generate an event using the EventDispatcher and send it to the right method using EventCallback.
  // Send an event
  EventDispatcher dispatcher = ...
 
  dispatcher.fireEvent(new MyEvent(), new MyCallback());
 
  // Inner class
  private static class MyCallBack implements EventCallback {
 
  public void eventFired(EventListener listener, EventObject event) {
 
      ((MyListener) listener).myEventOccured((MyEvent) event);
  }
    
Ok, the mechanism is a bit strange, but once you have implemented it you don't notice it anymore... ;-)

See Also:
EventDispatcher

Method Summary
 void eventFired(java.util.EventListener listener, java.util.EventObject event)
          Called by the EventDispatcher to send an event.
 

Method Detail

eventFired

public void eventFired(java.util.EventListener listener,
                       java.util.EventObject event)
Called by the EventDispatcher to send an event. Inmplement this method and translate the event to a type-safe method call.

Parameters:
listener - the event listener.
event - the event being sent.

Copyright 2005, Tryllian Solutions B.V.