Top Description Fields Constructors Methods
javafx.event

public final Class WeakEventHandler<T extends Event>

extends Object
implements EventHandler<T extends Event>
Class Inheritance
All Implemented Interfaces
javafx.event.EventHandler, java.util.EventListener
Type Parameters
<T>
the event class this handler can handle
Imports
java.lang.ref.WeakReference, javafx.beans.NamedArg

Used in event handler registration in place of its associated event handler. Its sole purpose is to break the otherwise strong reference between an event handler container and its associated event handler. While the container still holds strong reference to the registered WeakEventHandler proxy, the proxy itself references the original handler only weakly and so doesn't prevent it from being garbage collected. Until this weak reference is broken, any event notification received by the proxy is forwarded to the original handler.
Since
JavaFX 8.0

Field Summary

Modifier and TypeField and Description
private final WeakReference<EventHandler<T>>

Constructor Summary

AccessConstructor and Description
public
WeakEventHandler(final EventHandler<T>
the original event handler to which to forward event notifications
eventHandler
)

Creates a new instance of WeakEventHandler.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public void
handle(final T
the event which occurred
event
)

Implements javafx.event.EventHandler.handle.

Forwards event notification to the associated event handler.

public boolean

Returns:

true if the associated handler has been garbage collected, false otherwise
wasGarbageCollected
()

Indicates whether the associated event handler has been garbage collected.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

weakRefback to summary
private final WeakReference<EventHandler<T>> weakRef

Constructor Detail

WeakEventHandlerback to summary
public WeakEventHandler(final EventHandler<T> eventHandler)

Creates a new instance of WeakEventHandler.

Parameters
eventHandler:EventHandler<T>

the original event handler to which to forward event notifications

Method Detail

clearback to summary
pack-priv void clear()
handleback to summary
public void handle(final T event)

Implements javafx.event.EventHandler.handle.

Forwards event notification to the associated event handler.

Parameters
event:T

the event which occurred

Annotations
@Override
wasGarbageCollectedback to summary
public boolean wasGarbageCollected()

Indicates whether the associated event handler has been garbage collected. Used by containers to detect when the storage of corresponding references to this WeakEventHandler is no longer necessary.

Returns:boolean

true if the associated handler has been garbage collected, false otherwise