WeakSetChangeListener can be used, if an javafx.collections.ObservableSet
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.
WeakSetChangeListener are created by passing in the original
SetChangeListener. The WeakSetChangeListener should then be
registered to listen for changes of the observed object.
Note
You have to keep a reference to the SetChangeListener, that
was passed in as long as it is in use, otherwise it will be garbage collected
to soon.
SetChangeListener, ObservableSet, javafx.beans.WeakListener
| Modifier and Type | Field and Description |
|---|---|
| private final WeakReference |
| Access | Constructor and Description |
|---|---|
| public | WeakSetChangeListener(SetChangeListener<E>
The original listener that should be notified listener)The constructor of |
| Modifier and Type | Method and Description |
|---|---|
| public void | onChanged(SetChangeListener.
the change that was made changeImplements javafx. Called after a change has been made to an ObservableSet. |
| public boolean | wasGarbageCollected()
Implements javafx. Returns |
| ref | back to summary |
|---|---|
| private final WeakReference<SetChangeListener<E>> ref | |
| WeakSetChangeListener | back to summary |
|---|---|
| public WeakSetChangeListener(SetChangeListener<E> listener) The constructor of
| |
| onChanged | back to summary |
|---|---|
| public void onChanged(SetChangeListener. Implements javafx. Doc from javafx. Called after a change has been made to an ObservableSet. This method is called on every elementary change (add/remove) once. This means, complex changes like 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
| |