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
    Modifier
    Constructor
    Description
    protected
    GemsSkinBase(C control)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all registered listeners, event handlers, event filters, and subscriptions, then delegates to SkinBase.dispose().
    protected javafx.beans.InvalidationListener
    register(javafx.beans.Observable obs, javafx.beans.InvalidationListener listener)
    Adds an InvalidationListener to the given Observable and 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 a ChangeListener to the given ObservableValue and 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 a ListChangeListener to the given ObservableList and 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 a MapChangeListener to the given ObservableMap and tracks it for automatic removal when this skin is disposed.
    protected javafx.util.Subscription
    register(javafx.util.Subscription subscription)
    Registers a Subscription (e.g., from observable.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 given EventTarget and 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 given EventTarget and 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

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface javafx.scene.control.Skin

    install
  • Constructor Details

    • GemsSkinBase

      protected GemsSkinBase(C control)
  • Method Details

    • register

      protected javafx.beans.InvalidationListener register(javafx.beans.Observable obs, javafx.beans.InvalidationListener listener)
      Adds an InvalidationListener to the given Observable and 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 a ChangeListener to the given ObservableValue and 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 a ListChangeListener to the given ObservableList and 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 a MapChangeListener to the given ObservableMap and 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 given EventTarget and 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 given EventTarget and 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 a Subscription (e.g., from observable.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 to SkinBase.dispose().
      Specified by:
      dispose in interface javafx.scene.control.Skin<C extends javafx.scene.control.Control>
      Overrides:
      dispose in class javafx.scene.control.SkinBase<C extends javafx.scene.control.Control>