org.fest.swing.listener
Class WeakEventListener

java.lang.Object
  extended by org.fest.swing.listener.WeakEventListener
All Implemented Interfaces:
AWTEventListener, EventListener

public final class WeakEventListener
extends Object
implements AWTEventListener

Understands an event listener that wraps a given AWTEventListener and:

Author:
Alex Ruiz, Yvonne Wang

Method Summary
static WeakEventListener attachAsWeakEventListener(Toolkit toolkit, AWTEventListener listener, long eventMask)
          Creates a new WeakEventListener and adds it to the given Toolkit using the given event mask.
 void dispose()
          Removes itself from the Toolkit this listener is attached to.
 void eventDispatched(AWTEvent e)
          Dispatches the given event to the wrapped event listener.
 AWTEventListener underlyingListener()
          Returns the underlying listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

attachAsWeakEventListener

public static WeakEventListener attachAsWeakEventListener(Toolkit toolkit,
                                                          AWTEventListener listener,
                                                          long eventMask)
Creates a new WeakEventListener and adds it to the given Toolkit using the given event mask. The created WeakEventListener simply "decorates" the given AWTEventListener. All events dispatched to the WeakEventListener are re-routed to the underlying AWTEventListener. When the underlying AWTEventListener is garbage-collected, the WeakEventListener will remove itself from the toolkit.

Parameters:
toolkit - the given AWT Toolkit.
listener - the underlying listener to wrap.
eventMask - the event mask to use to attach the WeakEventListener to the toolkit.
Returns:
the created WeakEventListener.

underlyingListener

public AWTEventListener underlyingListener()
Returns the underlying listener.

Returns:
the underlying listener.

eventDispatched

public void eventDispatched(AWTEvent e)
Dispatches the given event to the wrapped event listener. If the wrapped listener is null (garbage-collected,) this listener will remove itself from the default toolkit.

Specified by:
eventDispatched in interface AWTEventListener
Parameters:
e - the event dispatched in the AWT.

dispose

public void dispose()
Removes itself from the Toolkit this listener is attached to.



Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.