EventHandler without Listener interface

Contains useful source code for specific use cases.

EventHandler without Listener interface

Postby Development@SIB » Tue May 10, 2011 8:23 am

EventHandler with and without parameters

Code: Select all
/** the event handler for captured (the event has one parameter: byte[]). */
private CallableHandler chCaptured = new CallableHandler(byte[].class);

/** the event handler for canceled (the event has no parameter). */
private CallableHandler chCanceled = new CallableHandler();

Event access

Code: Select all
/**
 * Gets the captured event handler.
 *
 * @return the event handler
 */
public CallableHandler eventCaptured()
{
   return chCaptured;
}

/**
 * Gets the canceled event handler.
 *
 * @return the event handler
 */
public CallableHandler eventCanceled()
{
   return chCanceled;
}


Dispatch events

Code: Select all
chCaptured.dispatchEvent(byData);
chCancel.dispatchEvent();

Listener registration:

Code: Select all
object.eventCaptured().addListener(this, "doCapture");

public void doCapture(byte[] pImage) throws Exception
{
    //...
}
User avatar
Development@SIB
 
Posts: 311
Joined: Mon Sep 28, 2009 1:54 pm

Return to Code snippets