Class GemsSkinBase<C extends javafx.scene.control.Control>
java.lang.Object
javafx.scene.control.SkinBase<C>
com.dlsc.gemsfx.skins.GemsSkinBase<C>
- Type Parameters:
C- the type of control rendered by this skin
- 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, SkeletonSkin, 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
ConstructorsModifierConstructorDescriptionprotectedGemsSkinBase(C control) Creates a skin for the given control. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Removes all registered listeners, event handlers, and event filters, 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 <E extends javafx.event.Event>
javafx.event.EventHandler<E> registerFilter(javafx.scene.Node target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> filter) Adds an event filter to the givenNodeand tracks it for automatic removal when this skin is disposed.protected <E extends javafx.event.Event>
javafx.event.EventHandler<E> registerHandler(javafx.scene.Node target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> handler) Adds an event handler to the givenNodeand 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, unregisterListChangeListeners
-
Constructor Details
-
GemsSkinBase
Creates a skin for the given control.- Parameters:
control- the control rendered by this skin
-
-
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.- Parameters:
obs- the observable to listen tolistener- the listener to add and later remove- 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.- Type Parameters:
T- the value type observed by the listener- Parameters:
obs- the observable value to listen tolistener- the listener to add and later remove- 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.- Type Parameters:
T- the list element type observed by the listener- Parameters:
list- the observable list to listen tolistener- the listener to add and later remove- 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.- Type Parameters:
K- the key type observed by the listenerV- the value type observed by the listener- Parameters:
map- the observable map to listen tolistener- the listener to add and later remove- Returns:
- the listener, for use as a field initializer
-
registerHandler
protected <E extends javafx.event.Event> javafx.event.EventHandler<E> registerHandler(javafx.scene.Node target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> handler) Adds an event handler to the givenNodeand tracks it for automatic removal when this skin is disposed.- Type Parameters:
E- the event type handled by the handler- Parameters:
target- the node receiving the handlertype- the event type to handlehandler- the handler to add and later remove- Returns:
- the handler, for use as a field initializer
-
registerFilter
protected <E extends javafx.event.Event> javafx.event.EventHandler<E> registerFilter(javafx.scene.Node target, javafx.event.EventType<E> type, javafx.event.EventHandler<E> filter) Adds an event filter to the givenNodeand tracks it for automatic removal when this skin is disposed.- Type Parameters:
E- the event type filtered by the filter- Parameters:
target- the node receiving the filtertype- the event type to filterfilter- the filter to add and later remove- Returns:
- the filter, for use as a field initializer
-
dispose
public void dispose()Removes all registered listeners, event handlers, and event filters, then delegates toSkinBase.dispose().
-