Class GemsSkinBase<C extends javafx.scene.control.Control>
java.lang.Object
javafx.scene.control.SkinBase<C>
com.dlsc.gemsfx.skins.GemsSkinBase<C>
- All Implemented Interfaces:
javafx.scene.control.Skin<C>
- Direct Known Subclasses:
ArcProgressIndicatorSkin, AvatarViewSkin, BeforeAfterViewSkin, CalendarViewSkin, ChipViewSkin, CustomComboBoxSkinBase, DateRangeViewSkin, EmailFieldSkin, FilterViewSkin, GridTableViewSkin, InfoCenterViewSkin, MaskedViewSkin, MultiColumnListViewSkin, PagingControlsSkin, PagingGridTableViewSkin, PagingListViewSkin, PhotoViewSkin, ScreensViewSkin, SearchFieldSkin, SearchFieldSkinBase, SegmentedBarSkin, SelectionBoxSkin, StripViewSkin, SVGImageViewSkin, TagsFieldSkin, TextViewSkin, YearMonthViewSkin, YearViewSkin
public abstract class GemsSkinBase<C extends javafx.scene.control.Control>
extends javafx.scene.control.SkinBase<C>
A base class for GemsFX skins that automatically tracks listener registrations
and removes them all in
dispose(), preventing memory leaks caused by
skins holding strong references on the skinnable control's observable properties.
Usage: instead of manually calling obs.addListener(l) in the constructor
and obs.removeListener(l) in dispose(), call register(obs, l).
The listener will be added immediately and removed automatically on disposal.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Removes all registered listeners, event handlers, event filters, and subscriptions, then delegates toSkinBase.dispose().protected javafx.beans.InvalidationListenerregister(javafx.beans.Observable obs, javafx.beans.InvalidationListener listener) Adds anInvalidationListenerto the givenObservableand tracks it for automatic removal when this skin is disposed.protected <T> javafx.beans.value.ChangeListener<T> register(javafx.beans.value.ObservableValue<T> obs, javafx.beans.value.ChangeListener<T> listener) Adds aChangeListenerto the givenObservableValueand tracks it for automatic removal when this skin is disposed.protected <T> javafx.collections.ListChangeListener<T> register(javafx.collections.ObservableList<T> list, javafx.collections.ListChangeListener<T> listener) Adds aListChangeListenerto the givenObservableListand tracks it for automatic removal when this skin is disposed.protected <K,V> javafx.collections.MapChangeListener <K, V> register(javafx.collections.ObservableMap<K, V> map, javafx.collections.MapChangeListener<K, V> listener) Adds aMapChangeListenerto the givenObservableMapand tracks it for automatic removal when this skin is disposed.protected javafx.util.Subscriptionregister(javafx.util.Subscription subscription) Registers aSubscription(e.g., fromobservable.subscribe(...)) for automatic cancellation when this skin is disposed.protected <E extends javafx.event.Event>
javafx.event.EventHandler<E> registerFilter(javafx.event.EventTarget target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> filter) Adds an event filter to the givenEventTargetand tracks it for automatic removal when this skin is disposed.protected <E extends javafx.event.Event>
javafx.event.EventHandler<E> registerHandler(javafx.event.EventTarget target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> handler) Adds an event handler to the givenEventTargetand tracks it for automatic removal when this skin is disposed.Methods inherited from class javafx.scene.control.SkinBase
computeBaselineOffset, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, consumeMouseEvents, executeAccessibleAction, getChildren, getClassCssMetaData, getCssMetaData, getNode, getSkinnable, layoutChildren, layoutInArea, layoutInArea, layoutInArea, positionInArea, positionInArea, pseudoClassStateChanged, queryAccessibleAttribute, registerChangeListener, registerInvalidationListener, registerListChangeListener, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, unregisterChangeListeners, unregisterInvalidationListeners, unregisterListChangeListenersMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javafx.scene.control.Skin
install
-
Constructor Details
-
GemsSkinBase
-
-
Method Details
-
register
protected javafx.beans.InvalidationListener register(javafx.beans.Observable obs, javafx.beans.InvalidationListener listener) Adds anInvalidationListenerto the givenObservableand tracks it for automatic removal when this skin is disposed.- Returns:
- the listener, for use as a field initializer
-
register
protected <T> javafx.beans.value.ChangeListener<T> register(javafx.beans.value.ObservableValue<T> obs, javafx.beans.value.ChangeListener<T> listener) Adds aChangeListenerto the givenObservableValueand tracks it for automatic removal when this skin is disposed.- Returns:
- the listener, for use as a field initializer
-
register
protected <T> javafx.collections.ListChangeListener<T> register(javafx.collections.ObservableList<T> list, javafx.collections.ListChangeListener<T> listener) Adds aListChangeListenerto the givenObservableListand tracks it for automatic removal when this skin is disposed.- Returns:
- the listener, for use as a field initializer
-
register
protected <K,V> javafx.collections.MapChangeListener<K,V> register(javafx.collections.ObservableMap<K, V> map, javafx.collections.MapChangeListener<K, V> listener) Adds aMapChangeListenerto the givenObservableMapand tracks it for automatic removal when this skin is disposed.- Returns:
- the listener, for use as a field initializer
-
registerHandler
protected <E extends javafx.event.Event> javafx.event.EventHandler<E> registerHandler(javafx.event.EventTarget target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> handler) Adds an event handler to the givenEventTargetand tracks it for automatic removal when this skin is disposed.- Returns:
- the handler, for use as a field initializer
-
registerFilter
protected <E extends javafx.event.Event> javafx.event.EventHandler<E> registerFilter(javafx.event.EventTarget target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> filter) Adds an event filter to the givenEventTargetand tracks it for automatic removal when this skin is disposed.- Returns:
- the filter, for use as a field initializer
-
register
protected javafx.util.Subscription register(javafx.util.Subscription subscription) Registers aSubscription(e.g., fromobservable.subscribe(...)) for automatic cancellation when this skin is disposed.- Returns:
- the subscription, for use as a field initializer
-
dispose
public void dispose()Removes all registered listeners, event handlers, event filters, and subscriptions, then delegates toSkinBase.dispose().
-