Class ModalBox

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.layout.Pane
javafx.scene.layout.AnchorPane
atlantafx.base.layout.ModalBox
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget

public class ModalBox extends javafx.scene.layout.AnchorPane
A specialized control (or layout) designed to hold the ModalPane dialog content. It includes the close button out-of-the-box and allows for the addition of arbitrary children.

The ModalBox is derived from the AnchorPane, so it inherits the same API. Just be sure that you haven't removed the close button while using it.

  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.BooleanProperty
    Specifies whether to remove (clear) the ModalPane content after it's closed.
    javafx.beans.property.ObjectProperty<javafx.event.EventHandler<? super javafx.event.Event>>
    The property representing the user specified close handler.

    Properties inherited from class javafx.scene.layout.Region

    background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width

    Properties inherited from class javafx.scene.Parent

    needsLayout

    Properties inherited from class javafx.scene.Node

    accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final javafx.beans.property.BooleanProperty
     
    protected final javafx.scene.layout.StackPane
     
    protected final javafx.scene.layout.StackPane
     
    protected @Nullable ModalPane
     
    protected final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<? super javafx.event.Event>>
     
    protected final @Nullable String
     

    Fields inherited from class javafx.scene.layout.Region

    USE_COMPUTED_SIZE, USE_PREF_SIZE

    Fields inherited from class javafx.scene.Node

    BASELINE_OFFSET_SAME_AS_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a ModalBox layout.
    ModalBox(@Nullable ModalPane modalPane, javafx.scene.Node... children)
    Creates a ModalBox layout with the given children and binds the close handler to a ModalPane.
    ModalBox(@Nullable String selector, javafx.scene.Node... children)
    Creates a ModalBox layout with the given children and binds the close handler to a ModalPane via CSS selector.
    ModalBox(javafx.scene.Node... children)
    Creates a ModalBox layout with the given children.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addContent(javafx.scene.Node node)
    Adds (prepends) specified node to the ModalBox before the close button.
    javafx.beans.property.BooleanProperty
    Specifies whether to remove (clear) the ModalPane content after it's closed.
    void
    Manually closes the ModalBox in case one needs to use their own close button.
    protected void
     
    javafx.event.EventHandler<? super javafx.event.Event>
    Gets the value of the property onClose.
    protected void
     
    boolean
    Gets the value of the property clearOnClose.
    javafx.beans.property.ObjectProperty<javafx.event.EventHandler<? super javafx.event.Event>>
    The property representing the user specified close handler.
    void
    setClearOnClose(boolean clearOnClose)
    Sets the value of the property clearOnClose.
    protected void
     
    void
    setOnClose(javafx.event.EventHandler<? super javafx.event.Event> onClose)
    Sets the value of the property onClose.

    Methods inherited from class javafx.scene.layout.AnchorPane

    clearConstraints, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBottomAnchor, getLeftAnchor, getRightAnchor, getTopAnchor, layoutChildren, setBottomAnchor, setLeftAnchor, setRightAnchor, setTopAnchor

    Methods inherited from class javafx.scene.layout.Pane

    getChildren

    Methods inherited from class javafx.scene.layout.Region

    backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty

    Methods inherited from class javafx.scene.Parent

    getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds

    Methods inherited from class javafx.scene.Node

    accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface javafx.css.Styleable

    getStyleableNode
  • Property Details

    • onClose

      public javafx.beans.property.ObjectProperty<javafx.event.EventHandler<? super javafx.event.Event>> onCloseProperty
      The property representing the user specified close handler.

      Note that if you have also specified the ModalPane instance or CSS selector, this handler will be executed after the default close handler. Therefore, you can use it to perform arbitrary actions on dialog close.

      See Also:
    • clearOnClose

      public javafx.beans.property.BooleanProperty clearOnCloseProperty
      Specifies whether to remove (clear) the ModalPane content after it's closed.
      See Also:
  • Field Details

    • closeButton

      protected final javafx.scene.layout.StackPane closeButton
    • closeButtonIcon

      protected final javafx.scene.layout.StackPane closeButtonIcon
    • selector

      @Nullable protected final @Nullable String selector
    • onClose

      protected final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<? super javafx.event.Event>> onClose
    • clearOnClose

      protected final javafx.beans.property.BooleanProperty clearOnClose
  • Constructor Details

    • ModalBox

      public ModalBox()
      Creates a ModalBox layout.
    • ModalBox

      public ModalBox(javafx.scene.Node... children)
      Creates a ModalBox layout with the given children.
      Parameters:
      children - The initial set of children for this pane.
    • ModalBox

      public ModalBox(@Nullable @Nullable String selector, javafx.scene.Node... children)
      Creates a ModalBox layout with the given children and binds the close handler to a ModalPane via CSS selector. When user clicks on the close button, it performs a ModalPane lookup via the specified selector and calls the ModalPane.hide() method automatically.
      Parameters:
      selector - The ModalPane pane CSS selector.
      children - The initial set of children for this pane.
    • ModalBox

      public ModalBox(@Nullable @Nullable ModalPane modalPane, javafx.scene.Node... children)
      Creates a ModalBox layout with the given children and binds the close handler to a ModalPane. When user clicks on the close button, it calls the ModalPane.hide() method automatically.
      Parameters:
      modalPane - The ModalPane pane CSS selector.
      children - The initial set of children for this pane.
  • Method Details

    • addContent

      public void addContent(javafx.scene.Node node)
      Adds (prepends) specified node to the ModalBox before the close button.

      Otherwise, if the added node takes up the full size of the ModalBox and Node.isMouseTransparent() is false, then the close button will not receive mouse events and therefore will not be clickable.

      Parameters:
      node - The node to be added.
    • close

      public void close()
      Manually closes the ModalBox in case one needs to use their own close button.
    • createLayout

      protected void createLayout()
    • setCloseButtonPosition

      protected void setCloseButtonPosition()
    • handleClose

      protected void handleClose()
    • onCloseProperty

      public javafx.beans.property.ObjectProperty<javafx.event.EventHandler<? super javafx.event.Event>> onCloseProperty()
      The property representing the user specified close handler.

      Note that if you have also specified the ModalPane instance or CSS selector, this handler will be executed after the default close handler. Therefore, you can use it to perform arbitrary actions on dialog close.

      See Also:
    • getOnClose

      public javafx.event.EventHandler<? super javafx.event.Event> getOnClose()
      Gets the value of the property onClose.
      Property description:
      The property representing the user specified close handler.

      Note that if you have also specified the ModalPane instance or CSS selector, this handler will be executed after the default close handler. Therefore, you can use it to perform arbitrary actions on dialog close.

    • setOnClose

      public void setOnClose(javafx.event.EventHandler<? super javafx.event.Event> onClose)
      Sets the value of the property onClose.
      Property description:
      The property representing the user specified close handler.

      Note that if you have also specified the ModalPane instance or CSS selector, this handler will be executed after the default close handler. Therefore, you can use it to perform arbitrary actions on dialog close.

    • clearOnCloseProperty

      public javafx.beans.property.BooleanProperty clearOnCloseProperty()
      Specifies whether to remove (clear) the ModalPane content after it's closed.
      See Also:
    • isClearOnClose

      public boolean isClearOnClose()
      Gets the value of the property clearOnClose.
      Property description:
      Specifies whether to remove (clear) the ModalPane content after it's closed.
    • setClearOnClose

      public void setClearOnClose(boolean clearOnClose)
      Sets the value of the property clearOnClose.
      Property description:
      Specifies whether to remove (clear) the ModalPane content after it's closed.