Class Layer

  • All Implemented Interfaces:
    Styleable, EventTarget
    Direct Known Subclasses:
    PopupView, SidePopupView

    public class Layer
    extends Pane

    A Layer is an overlay that can be shown above any View. Layer is managed by GlassPane and is automatically added/removed depending on the value of the showingProperty().

    A Layer follows a life cycle triggering various life cycle events during the process. The life cycle event 'showing' is called as soon as show() is called followed by playing the show transition. Once the show transition is complete, the life cycle event 'shown' is triggered. Similarly, when hide() is called, life cycle event 'hiding' is triggered followed by a call to 'hidden' event when the hide transition has completed animating.

    A background fade can be set by calling setBackgroundFade(double) this will fade the background to a darker color, bringing more attention to what is shown by this layer making it distinct from the content underneath. The background can also be set transparent to mouse events by using Node.mouseTransparentProperty().

    Since:
    1.0.0
    See Also:
    View, GlassPane, AppManager
    • Constructor Detail

      • Layer

        public Layer()
        Creates a new Layer instance.
    • Method Detail

      • isShowing

        public final boolean isShowing()
        Gets the value of the property showing.
        Property description:
        Represents whether this Layer is currently showing on screen or not.
      • autoHideProperty

        public final BooleanProperty autoHideProperty()
        Represents whether this Layer should hide when it is clicked outside its bounds.When set to false, the background is transparent to mouse events.
        Default value:
        true
        See Also:
        isAutoHide(), setAutoHide(boolean)
      • isAutoHide

        public final boolean isAutoHide()
        Gets the value of the property autoHide.
        Property description:
        Represents whether this Layer should hide when it is clicked outside its bounds.When set to false, the background is transparent to mouse events.
        Default value:
        true
      • setAutoHide

        public final void setAutoHide​(boolean value)
        Sets the value of the property autoHide.
        Property description:
        Represents whether this Layer should hide when it is clicked outside its bounds.When set to false, the background is transparent to mouse events.
        Default value:
        true
      • getShowTransitionFactory

        public final Function<Layer,​Transition> getShowTransitionFactory()
        Gets the value of the property showTransitionFactory.
        Property description:
        The factory that returns the Transition for the given layer which should be used during its appearance.
        Since:
        5.0.0
      • setShowTransitionFactory

        public final void setShowTransitionFactory​(Function<Layer,​Transition> value)
        Sets the value of the property showTransitionFactory.
        Property description:
        The factory that returns the Transition for the given layer which should be used during its appearance.
        Since:
        5.0.0
      • getHideTransitionFactory

        public final Function<Layer,​Transition> getHideTransitionFactory()
        Gets the value of the property hideTransitionFactory.
        Property description:
        The factory that returns the Transition for the given layer which should be used during its disappearance.
        Since:
        5.0.0
      • setHideTransitionFactory

        public final void setHideTransitionFactory​(Function<Layer,​Transition> value)
        Sets the value of the property hideTransitionFactory.
        Property description:
        The factory that returns the Transition for the given layer which should be used during its disappearance.
        Since:
        5.0.0
      • setBackgroundFade

        public final void setBackgroundFade​(double level)
        Sets the value of the property backgroundFade.
        Property description:
        Sets a background fade making the background a darker color and with this bringing more attention to what is shown by this Layer.
        Default value:
        0.0
      • getBackgroundFade

        public final double getBackgroundFade()
        Gets the value of the property backgroundFade.
        Property description:
        Sets a background fade making the background a darker color and with this bringing more attention to what is shown by this Layer.
        Default value:
        0.0
      • setOnShowing

        public final void setOnShowing​(EventHandler<LifecycleEvent> value)
        Sets the value of the property onShowing.
        Property description:
        Called just prior to the Layer being shown. This happens just before the show transition starts.
        Since:
        5.0.0
      • getOnShowing

        public final EventHandler<LifecycleEvent> getOnShowing()
        Gets the value of the property onShowing.
        Property description:
        Called just prior to the Layer being shown. This happens just before the show transition starts.
        Since:
        5.0.0
      • setOnShown

        public final void setOnShown​(EventHandler<LifecycleEvent> value)
        Sets the value of the property onShown.
        Property description:
        Called just after the Layer is shown. This happens just after the show transition ends.
        Since:
        5.0.0
      • getOnShown

        public final EventHandler<LifecycleEvent> getOnShown()
        Gets the value of the property onShown.
        Property description:
        Called just after the Layer is shown. This happens just after the show transition ends.
        Since:
        5.0.0
      • setOnHiding

        public final void setOnHiding​(EventHandler<LifecycleEvent> value)
        Sets the value of the property onHiding.
        Property description:
        Called just prior to the Layer being hidden. This happens just before the hide transition starts.
        Since:
        5.0.0
      • getOnHiding

        public final EventHandler<LifecycleEvent> getOnHiding()
        Gets the value of the property onHiding.
        Property description:
        Called just prior to the Layer being hidden. This happens just before the hide transition starts.
        Since:
        5.0.0
      • setOnHidden

        public final void setOnHidden​(EventHandler<LifecycleEvent> value)
        Sets the value of the property onHidden.
        Property description:
        Called just after the Layer has been hidden. This happens just after the hide transition ends. This allows the developer to clean up resources or perform other tasks when the Layer is hidden.
        Since:
        5.0.0
      • getOnHidden

        public final EventHandler<LifecycleEvent> getOnHidden()
        Gets the value of the property onHidden.
        Property description:
        Called just after the Layer has been hidden. This happens just after the hide transition ends. This allows the developer to clean up resources or perform other tasks when the Layer is hidden.
        Since:
        5.0.0
      • hide

        public void hide()
        If this layer is showing, calling this method will hide it. If a hide transition is present, it is played before hiding the Layer. Care should be taken to call this only once LifecycleEvent.SHOWN has been fired.

        LifecycleEvent.HIDING is fired as soon as the method is called. LifecycleEvent.HIDDEN is fired after the hide transition has finished.

        No-op if showingProperty() is false.

      • layoutChildren

        public void layoutChildren()
        Override this method to add the layout logic for your layer. Care should be taken to call this method in overriden methods for proper functioning of the Layer.
        Overrides:
        layoutChildren in class Parent