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