Top Description Inners Fields Constructors Methods
com.sun.javafx.scene.control

public Class ListenerHelper

extends Object
implements IDisconnectable
Class Inheritance
All Implemented Interfaces
com.sun.javafx.scene.control.IDisconnectable
Imports
java.lang.ref.WeakReference, java.util.ArrayList, java.util.function.Consumer, .Function, javafx.beans.InvalidationListener, .Observable, javafx.beans.value.ChangeListener, .ObservableValue, javafx.collections.ListChangeListener, .MapChangeListener, .ObservableList, .ObservableMap, .ObservableSet, .SetChangeListener, javafx.event.Event, .EventHandler, .EventTarget, .EventType, javafx.scene.control.SkinBase

This class provides convenience methods for adding various listeners, both strong and weak, as well as a single disconnect() method to remove all listeners.

There are two usage patterns:

This class is currently used for clean replacement of Skins. We should consider making this class a part of the public API in javax.base, since it proved itself useful in removing listeners and handlers in bulk at the application level.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
private abstract class
private abstract static class
private abstract static class
private abstract static class
private abstract static class

Field Summary

Modifier and TypeField and Description
private static Function<SkinBase<?>, ListenerHelper>
private final ArrayList<IDisconnectable>
private WeakReference<Object>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public IDisconnectable
public IDisconnectable
addChangeListener(Runnable onChange, boolean fireImmediately, ObservableValue<?>... props)

public <T> IDisconnectable
public <T> IDisconnectable
addChangeListener(ObservableValue<T> prop, boolean fireImmediately, ChangeListener<T> listener)

public <T> IDisconnectable
public <T> IDisconnectable
addChangeListener(ObservableValue<T> prop, boolean fireImmediately, Consumer<T> callback)

public IDisconnectable
public <T extends Event> IDisconnectable
public <T extends Event> IDisconnectable
public IDisconnectable
public IDisconnectable
addInvalidationListener(Runnable callback, boolean fireImmediately, ObservableValue<?>... props)

public <T> IDisconnectable
public <T> IDisconnectable
addInvalidationListener(ObservableValue<T> prop, boolean fireImmediately, InvalidationListener listener)

public <T> IDisconnectable
public <K, V> IDisconnectable
public <T> IDisconnectable
public void
disconnect()

Implements com.sun.javafx.scene.control.IDisconnectable.disconnect.

Disconnects what has been connected.

public static ListenerHelper
get(SkinBase<?> skin)

private boolean
public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessorback to summary
private static Function<SkinBase<?>, ListenerHelper> accessor
itemsback to summary
private final ArrayList<IDisconnectable> items
ownerRefback to summary
private WeakReference<Object> ownerRef

Constructor Detail

ListenerHelperback to summary
public ListenerHelper(Object owner)
ListenerHelperback to summary
public ListenerHelper()

Method Detail

addChangeListenerback to summary
public IDisconnectable addChangeListener(Runnable callback, ObservableValue<?>... props)
addChangeListenerback to summary
public IDisconnectable addChangeListener(Runnable onChange, boolean fireImmediately, ObservableValue<?>... props)
addChangeListenerback to summary
public <T> IDisconnectable addChangeListener(ObservableValue<T> prop, ChangeListener<T> listener)
addChangeListenerback to summary
public <T> IDisconnectable addChangeListener(ObservableValue<T> prop, boolean fireImmediately, ChangeListener<T> listener)
addChangeListenerback to summary
public <T> IDisconnectable addChangeListener(ObservableValue<T> prop, Consumer<T> callback)
addChangeListenerback to summary
public <T> IDisconnectable addChangeListener(ObservableValue<T> prop, boolean fireImmediately, Consumer<T> callback)
addDisconnectableback to summary
public IDisconnectable addDisconnectable(Runnable r)
addEventFilterback to summary
public <T extends Event> IDisconnectable addEventFilter(EventTarget x, EventType<T> t, EventHandler<T> handler)
addEventHandlerback to summary
public <T extends Event> IDisconnectable addEventHandler(EventTarget x, EventType<T> t, EventHandler<T> handler)
addInvalidationListenerback to summary
public IDisconnectable addInvalidationListener(Runnable callback, ObservableValue<?>... props)
addInvalidationListenerback to summary
public IDisconnectable addInvalidationListener(Runnable callback, boolean fireImmediately, ObservableValue<?>... props)
addInvalidationListenerback to summary
public <T> IDisconnectable addInvalidationListener(ObservableValue<T> prop, InvalidationListener listener)
addInvalidationListenerback to summary
public <T> IDisconnectable addInvalidationListener(ObservableValue<T> prop, boolean fireImmediately, InvalidationListener listener)
addListChangeListenerback to summary
public <T> IDisconnectable addListChangeListener(ObservableList<T> list, ListChangeListener<T> listener)
addMapChangeListenerback to summary
public <K, V> IDisconnectable addMapChangeListener(ObservableMap<K, V> list, MapChangeListener<K, V> listener)
addSetChangeListenerback to summary
public <T> IDisconnectable addSetChangeListener(ObservableSet<T> set, SetChangeListener<T> listener)
disconnectback to summary
public void disconnect()

Implements com.sun.javafx.scene.control.IDisconnectable.disconnect.

Doc from com.sun.javafx.scene.control.IDisconnectable.disconnect.

Disconnects what has been connected. May be called multiple times, only the first invocation actually disconnects.

Annotations
@Override
getback to summary
public static ListenerHelper get(SkinBase<?> skin)
isAliveOrDisconnectback to summary
private boolean isAliveOrDisconnect()
setAccessorback to summary
public static void setAccessor(Function<SkinBase<?>, ListenerHelper> a)
com.sun.javafx.scene.control back to summary

private abstract Class ListenerHelper.ChLi<T>

extends Object
implements IDisconnectable, ChangeListener<T>
Class Inheritance
All Implemented Interfaces
javafx.beans.value.ChangeListener, com.sun.javafx.scene.control.IDisconnectable

Constructor Summary

AccessConstructor and Description
private
ChLi()

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ChLiback to summary
private ChLi()
com.sun.javafx.scene.control back to summary

private abstract Class ListenerHelper.EvHa<T extends Event>

extends Object
implements IDisconnectable, EventHandler<T extends Event>
Class Inheritance
All Implemented Interfaces
javafx.event.EventHandler, java.util.EventListener, com.sun.javafx.scene.control.IDisconnectable

Field Summary

Modifier and TypeField and Description
private final EventHandler<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
handle(T
the event which occurred
ev
)

Implements javafx.event.EventHandler.handle.

Invoked when a specific event of the type for which this handler is registered happens.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlerback to summary
private final EventHandler<T> handler

Constructor Detail

EvHaback to summary
public EvHa(EventHandler<T> h)

Method Detail

handleback to summary
public void handle(T ev)

Implements javafx.event.EventHandler.handle.

Doc from javafx.event.EventHandler.handle.

Invoked when a specific event of the type for which this handler is registered happens.

Parameters
ev:T

the event which occurred

Annotations
@Override
com.sun.javafx.scene.control back to summary

private abstract Class ListenerHelper.InLi

extends Object
implements IDisconnectable, InvalidationListener
Class Inheritance
All Implemented Interfaces
javafx.beans.InvalidationListener, com.sun.javafx.scene.control.IDisconnectable

Constructor Summary

AccessConstructor and Description
private
InLi()

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

InLiback to summary
private InLi()
com.sun.javafx.scene.control back to summary

private abstract Class ListenerHelper.LiChLi<T>

extends Object
implements IDisconnectable, ListChangeListener<T>
Class Inheritance
All Implemented Interfaces
javafx.collections.ListChangeListener, com.sun.javafx.scene.control.IDisconnectable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LiChLiback to summary
private LiChLi()
com.sun.javafx.scene.control back to summary

private abstract Class ListenerHelper.MaChLi<K, V>

extends Object
implements IDisconnectable, MapChangeListener<K, V>
Class Inheritance
All Implemented Interfaces
javafx.collections.MapChangeListener, com.sun.javafx.scene.control.IDisconnectable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MaChLiback to summary
private MaChLi()
com.sun.javafx.scene.control back to summary

private abstract Class ListenerHelper.SeChLi<T>

extends Object
implements IDisconnectable, SetChangeListener<T>
Class Inheritance
All Implemented Interfaces
javafx.collections.SetChangeListener, com.sun.javafx.scene.control.IDisconnectable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SeChLiback to summary
private SeChLi()