WeakMapChangeListener can be used, if an javafx.collections.ObservableMap
should only maintain a weak reference to the listener. This helps to avoid
memory leaks, that can occur if observers are not unregistered from observed
objects after use.
WeakMapChangeListener are created by passing in the original
javafx.. The WeakMapChangeListener should then be
registered to listen for changes of the observed object.
Note
You have to keep a reference to the MapChangeListener, that
was passed in as long as it is in use, otherwise it will be garbage collected
to soon.
MapChangeListener, ObservableMap, javafx.beans.WeakListener
| Modifier and Type | Field and Description |
|---|---|
| private final WeakReference |
| Access | Constructor and Description |
|---|---|
| public | WeakMapChangeListener(MapChangeListener<K, V>
The original listener that should be notified listener)The constructor of |
| Modifier and Type | Method and Description |
|---|---|
| public void | onChanged(MapChangeListener.
the change that was made changeImplements javafx. Called after a change has been made to an ObservableMap. |
| public boolean | wasGarbageCollected()
Implements javafx. Returns |
| ref | back to summary |
|---|---|
| private final WeakReference<MapChangeListener<K, V>> ref | |
| WeakMapChangeListener | back to summary |
|---|---|
| public WeakMapChangeListener(MapChangeListener<K, V> listener) The constructor of
| |
| onChanged | back to summary |
|---|---|
| public void onChanged(MapChangeListener. Implements javafx. Doc from javafx. Called after a change has been made to an ObservableMap. This method is called on every elementary change (put/remove) once. This means, complex changes like keySet().removeAll(Collection) or clear() may result in more than one call of onChanged method.
| |
| wasGarbageCollected | back to summary |
|---|---|
| public boolean wasGarbageCollected() Implements javafx. Doc from javafx. Returns
| |