public class TLcdAWTEventDispatcher extends Object implements ILcdAWTEventListener, ILcdAWTEventSource
This class is the central access point for dispatching AWTEvent
(extensions)
and informing all interested parties about it.
Events are dispatched to their source
when this source
is an instance of Component
.
Typically this source will be the most specific
component matching with the event. For example, for a touch event this could be the deepest
component overlapping with the touch
coordinates.
Listeners can be added to this class which will be warned when an event is dispatched. This allows to listen to all events which are inserted into the application.
// add our listener to the dispatcher
aEventDispatcher.addEventListener( new ILcdAWTEventListener(){
public void handleAWTEvent( AWTEvent aEvent ) {
// do something with the event
} };
This is especially useful for debugging purposes.
All methods should be called from the Event Dispatch Thread (EDT).
Modifier and Type | Method and Description |
---|---|
void |
addAWTEventListener(ILcdAWTEventListener aEventListener)
Register an
AWTEventListener which will be informed every time an event is
dispatched into the application using this TLcdAWTEventDispatcher . |
static TLcdAWTEventDispatcher |
getInstance()
Returns a static instance of
TLcdAWTEventDispatcher . |
void |
handleAWTEvent(AWTEvent aEvent)
Dispatches an event, and inform all registered listeners about the event.
|
void |
removeAWTEventListener(ILcdAWTEventListener aEventListener)
Remove an
AWTEventListener which was added previously so it will no longer be
informed about events which are dispatched into the application. |
public static TLcdAWTEventDispatcher getInstance()
TLcdAWTEventDispatcher
. This technique is known as the
singleton pattern.TLcdAWTEventDispatcher
.public void handleAWTEvent(AWTEvent aEvent)
Dispatches an event, and inform all registered listeners about the event.
The event is directly dispatched to its source.handleAWTEvent
in interface ILcdAWTEventListener
aEvent
- the event to dispatch. Only AWTEvent of which the source is an instance of Component
are dispatched.addAWTEventListener(ILcdAWTEventListener)
public void addAWTEventListener(ILcdAWTEventListener aEventListener)
Register an AWTEventListener
which will be informed every time an event is
dispatched into the application using this TLcdAWTEventDispatcher
.
addAWTEventListener
in interface ILcdAWTEventSource
aEventListener
- the listenerremoveAWTEventListener(ILcdAWTEventListener)
public void removeAWTEventListener(ILcdAWTEventListener aEventListener)
Remove an AWTEventListener
which was added previously so it will no longer be
informed about events which are dispatched into the application.
removeAWTEventListener
in interface ILcdAWTEventSource
aEventListener
- the listeneraddAWTEventListener(ILcdAWTEventListener)