Parent (JavaFX 28)
Description: declaration: module: javafx.graphics, package: javafx.scene, class: Parent

# Class Parent

java.lang.Object
javafx.scene.Node
javafx.scene.Parent

All Implemented Interfaces:
  `Styleable, EventTarget`

Direct Known Subclasses:
  `Group, Region, WebView`

public abstract non-sealed class Parent extends Node
The base class for all nodes that have children in the scene graph.

This class handles all hierarchical scene graph operations, including adding/removing child nodes, marking branches dirty for layout and rendering, picking, bounds calculations, and executing the layout pass on each pulse.

There are two direct concrete Parent subclasses

- `Group` effects and transforms to be applied to a collection of child nodes.
- `Region` class for nodes that can be styled with CSS and layout children.

Since:
  JavaFX 2.0

- ## Property Summary

  Properties
  Type
  Property
  Description
  `final ReadOnlyBooleanProperty`
  `needsLayout`
  Indicates that this Node and its subnodes requires a layout pass on the next pulse.

  ### Properties declared in class 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, onMouseDragDone, 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 declared in class Node

  `BASELINE_OFFSET_SAME_AS_HEIGHT`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `Parent()`
  Constructs a new `Parent`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected double`
  `computeMinHeight(double width)`
  Computes the minimum height for the specified width.
  `protected double`
  `computeMinWidth(double height)`
  Computes the minimum width for the specified height.
  `protected double`
  `computePrefHeight(double width)`
  Computes the preferred height for the specified width.
  `protected double`
  `computePrefWidth(double height)`
  Computes the preferred width for the specified height.
  `double`
  `getBaselineOffset()`
  Calculates the baseline offset based on the first managed child.
  `protected ObservableList<Node>`
  `getChildren()`
  Gets the list of children of this `Parent`.
  `ObservableList<Node>`
  `getChildrenUnmodifiable()`
  Gets the list of children of this `Parent` as a read-only list.
  `protected <E extends Node>
  List<E>`
  `getManagedChildren()`
  Gets the list of all managed children of this `Parent`.
  `final ObservableList<String>`
  `getStylesheets()`
  Gets an observable list of string URLs linking to the stylesheets to use with this Parent's contents.
  `final boolean`
  `isNeedsLayout()`
  Gets the value of the `needsLayout` property.
  `final void`
  `layout()`
  Executes a top-down layout pass on the scene graph under this parent.
  `protected void`
  `layoutChildren()`
  Invoked by `layout()` during a layout pass to position and resize the managed children.
  `final ReadOnlyBooleanProperty`
  `needsLayoutProperty()`
  Indicates that this Node and its subnodes requires a layout pass on the next pulse.
  `void`
  `requestLayout()`
  Requests a layout pass to be performed before the next scene is rendered.
  `protected final void`
  `requestParentLayout()`
  Requests a layout pass of the parent to be performed before the next scene is rendered.
  `protected final void`
  `setNeedsLayout(boolean value)`
  Sets the value of the `needsLayout` property.
  `protected void`
  `updateBounds()`
  Updates the bounds of this `Parent` and its children.

  ### Methods declared in class 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, getClassCssMetaData, getClip, getContentBias, getCssMetaData, 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, getOnMouseDragDone, 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, isResizable, 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, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragDoneProperty, 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, prefHeight, prefWidth, pressedProperty, pseudoClassStateChanged, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, requestFocusTraversal, resize, 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, setOnMouseDragDone, 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 declared in class Object

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

  ### Methods declared in interface Styleable

  `getStyleableNode`

- ## Property Details

  - ### needsLayout

    public final ReadOnlyBooleanProperty needsLayoutProperty
    Indicates that this Node and its subnodes requires a layout pass on the next pulse.
    See Also:
      - `isNeedsLayout()`
      - `setNeedsLayout(boolean)`
      - `needsLayoutProperty()`

- ## Constructor Details

  - ### Parent

    protected Parent()
    Constructs a new `Parent`.

- ## Method Details

  - ### getChildren

    protected ObservableList<Node> getChildren()
    Gets the list of children of this `Parent`.

    See the class documentation for `Node` for scene graph structure restrictions on setting a `Parent`'s children list. If these restrictions are violated by a change to the list of children, the change is ignored and the previous value of the children list is restored. An `IllegalArgumentException` is thrown in this case.

    If this `Parent` node is attached to a `Scene` attached to a `Window`, that is, showing (`Window.isShowing()`), then its list of children must only be modified on the JavaFX Application Thread. An `IllegalStateException` is thrown if this restriction is violated.

    Note to subclasses: if you override this method, you must return from your implementation the result of calling this super method. The actual list instance returned from any getChildren() implementation must be the list owned and managed by this Parent. The only typical purpose for overriding this method is to promote the method to be public.

    Returns:
      the list of children of this `Parent`.

  - ### getChildrenUnmodifiable

    public ObservableList<Node> getChildrenUnmodifiable()
    Gets the list of children of this `Parent` as a read-only list.
    Returns:
      read-only access to this parent's children ObservableList

  - ### getManagedChildren

    protected <E extends Node> List<E> getManagedChildren()
    Gets the list of all managed children of this `Parent`.
    Type Parameters:
      `E` - the type of the children nodes
    Returns:
      list of all managed children in this parent

  - ### setNeedsLayout

    protected final void setNeedsLayout(boolean value)
    Sets the value of the `needsLayout` property.
    Property description:
      Indicates that this Node and its subnodes requires a layout pass on the next pulse.
    Parameters:
      `value` - the value for the `needsLayout` property
    See Also:
      - `isNeedsLayout()`
      - `needsLayoutProperty()`

  - ### isNeedsLayout

    public final boolean isNeedsLayout()
    Gets the value of the `needsLayout` property.
    Property description:
      Indicates that this Node and its subnodes requires a layout pass on the next pulse.
    Returns:
      the value of the `needsLayout` property
    See Also:
      - `setNeedsLayout(boolean)`
      - `needsLayoutProperty()`

  - ### needsLayoutProperty

    public final ReadOnlyBooleanProperty needsLayoutProperty()
    Indicates that this Node and its subnodes requires a layout pass on the next pulse.
    Returns:
      the `needsLayout` property
    See Also:
      - `isNeedsLayout()`
      - `setNeedsLayout(boolean)`

  - ### requestLayout

    public void requestLayout()
    Requests a layout pass to be performed before the next scene is rendered. This is batched up asynchronously to happen once per "pulse", or frame of animation.

    If this parent is either a scene root or unmanaged, then it will be added directly to the scene's dirty layout list, otherwise requestParentLayout will be invoked.

    Since:
      JavaFX 8.0

  - ### requestParentLayout

    protected final void requestParentLayout()
    Requests a layout pass of the parent to be performed before the next scene is rendered. This is batched up asynchronously to happen once per "pulse", or frame of animation.

    This may be used when the current parent have changed it's min/max/preferred width/height, but doesn't know yet if the change will lead to it's actual size change. This will be determined when it's parent recomputes the layout with the new hints.

  - ### computePrefWidth

    protected double computePrefWidth(double height)
    Computes the preferred width for the specified height.

    An overriding implementation should be consistent with the layout policy implemented by `layoutChildren()`. If pixel snapping is used, corresponding measurement and layout calculations must use the same snapped values.

    Implementation Note:
      The default implementation computes the horizontal span containing the parent's origin and all managed children. It uses each child's current layout position and preferred width, constrained by the child's minimum and maximum widths. The `height` parameter is ignored.
    Parameters:
      `height` - the height on which to base the preferred width, or `-1` if no height is specified
    Returns:
      the computed preferred width
    See Also:
      - Pixel Snapping

  - ### computePrefHeight

    protected double computePrefHeight(double width)
    Computes the preferred height for the specified width.

    An overriding implementation should be consistent with the layout policy implemented by `layoutChildren()`. If pixel snapping is used, corresponding measurement and layout calculations must use the same snapped values.

    Implementation Note:
      The default implementation computes the vertical span containing the parent's origin and all managed children. It uses each child's current layout position and preferred height, constrained by the child's minimum and maximum heights. The `width` parameter is ignored.
    Parameters:
      `width` - the width on which to base the preferred height, or `-1` if no width is specified
    Returns:
      the computed preferred height
    See Also:
      - Pixel Snapping

  - ### computeMinWidth

    protected double computeMinWidth(double height)
    Computes the minimum width for the specified height.

    An overriding implementation should be consistent with the layout policy implemented by `layoutChildren()`. If pixel snapping is used, corresponding measurement and layout calculations must use the same snapped values.

    Implementation Note:
      The default implementation returns `prefWidth(height)`.
    Parameters:
      `height` - the height on which to base the minimum width, or `-1` if no height is specified
    Returns:
      the computed minimum width
    Since:
      JavaFX 2.1
    See Also:
      - Pixel Snapping

  - ### computeMinHeight

    protected double computeMinHeight(double width)
    Computes the minimum height for the specified width.

    An overriding implementation should be consistent with the layout policy implemented by `layoutChildren()`. If pixel snapping is used, corresponding measurement and layout calculations must use the same snapped values.

    Implementation Note:
      The default implementation returns `prefHeight(width)`.
    Parameters:
      `width` - the width on which to base the minimum height, or `-1` if no width is specified
    Returns:
      the computed minimum height
    Since:
      JavaFX 2.1
    See Also:
      - Pixel Snapping

  - ### getBaselineOffset

    public double getBaselineOffset()
    Calculates the baseline offset based on the first managed child. If there is no such child, returns `Node.getBaselineOffset()`.
    Overrides:
      `getBaselineOffset` in class `Node`
    Returns:
      baseline offset

  - ### layout

    public final void layout()
    Executes a top-down layout pass on the scene graph under this parent. Calling this method while the Parent is doing layout is a no-op.

  - ### layoutChildren

    protected void layoutChildren()
    Invoked by `layout()` during a layout pass to position and resize the managed children.

    Subclasses should override this method to implement their layout policy. When pixel snapping is used, this parent owns the snapping policy for the positions and sizes it allocates to its children. The snapped allocations made here must be consistent with the corresponding minimum-size and preferred-size calculations.

    Implementation Requirements:
      The default implementation invokes `Node.autosize()` on each managed, resizable child and leaves all child positions unchanged.
    See Also:
      - Pixel Snapping

  - ### getStylesheets

    public final ObservableList<String> getStylesheets()
    Gets an observable list of string URLs linking to the stylesheets to use with this Parent's contents. See `Scene.getStylesheets()` for details.

    For additional information about using CSS with the scene graph, see the CSS Reference Guide.

    Returns:
      the list of stylesheets to use with this Parent
    Since:
      JavaFX 2.1

  - ### updateBounds

    protected void updateBounds()
    Updates the bounds of this `Parent` and its children.