APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.layout

public Class Pane

extends Region
Class Inheritance
Known Direct Subclasses
javafx.scene.layout.StackPane, javafx.scene.layout.TilePane, javafx.scene.layout.VBox, javafx.scene.text.TextFlow, javafx.scene.layout.AnchorPane, javafx.scene.layout.BorderPane, javafx.scene.layout.FlowPane, javafx.scene.layout.GridPane, javafx.scene.layout.HBox
Annotations
@DefaultProperty:children
Imports
com.sun.javafx.scene.layout.PaneHelper, javafx.beans.DefaultProperty, javafx.collections.ObservableList, javafx.scene.Node

Base class for layout panes which need to expose the children list as public so that users of the subclass can freely add/remove children.

This class may be used directly in cases where absolute positioning of children is required since it does not perform layout beyond resizing resizable children to their preferred sizes. It is the application's responsibility to position the children since the pane leaves the positions alone during layout. For example:

Pane canvas = new Pane();
    canvas.setStyle("-fx-background-color: black;");
    canvas.setPrefSize(200,200);
    Circle circle = new Circle(50,Color.BLUE);
    circle.relocate(20, 20);
    Rectangle rectangle = new Rectangle(100,100,Color.RED);
    rectangle.relocate(70,70);
    canvas.getChildren().addAll(circle,rectangle);

Note

if an application needs children to be kept aligned within a parent (centered, positioned at top-left, etc), it should use a StackPane instead.

Pane resizes each managed child regardless of the child's visible property value; unmanaged children are ignored for all layout calculations.

Resizable Range

A pane's parent will resize the pane within the pane's resizable range during layout. By default the pane computes this range based on its content as outlined in the table below:

Pane Resize Table
widthheight
minimum left plus right insets. top plus bottom insets.
preferred width required to encompass each child at its current x location and preferred width. height required to encompass each child at its current y location and preferred height.
maximum Double.MAX_VALUEDouble.MAX_VALUE

A pane's unbounded maximum width and height are an indication to the parent that it may be resized beyond its preferred size to fill whatever space is assigned to it.

Pane provides properties for setting the size range directly. These properties default to the sentinel value Region.USE_COMPUTED_SIZE, however the application may set them to other values as needed:


    pane.setPrefSize(500,400);
Applications may restore the computed values by setting these properties back to Region.USE_COMPUTED_SIZE.

Pane does not clip its content by default, so it is possible that children's bounds may extend outside its own bounds, either if children are positioned at negative coordinates or the pane is resized smaller than its preferred size.

Since
JavaFX 2.0

Field Summary

Inherited from javafx.scene.layout.Region:
TEMP_VEC2DUSE_COMPUTED_SIZEUSE_PREF_SIZE

Constructor Summary

AccessConstructor and Description
public
Pane()

Creates a Pane layout.

public
Pane(Node...
The initial set of children for this pane.
children
)

Creates a Pane layout.

Method Summary

Modifier and TypeMethod and Description
public ObservableList<Node>

Returns:

modifiable list of children.
getChildren
()

Overrides javafx.scene.Parent.getChildren.

Gets the list of children of this Parent.

pack-priv static Object
pack-priv static void
setConstraint(Node node, Object key, Object value)

Inherited from javafx.scene.layout.Region:
addImageListeneradjustHeightByMarginadjustWidthByMarginbackgroundPropertyborderPropertyboundedNodeSizeWithBiasboundedSizecacheShapePropertycenterShapePropertycomputeChildMaxAreaHeightcomputeChildMaxAreaWidthcomputeChildMinAreaHeightcomputeChildMinAreaHeightcomputeChildMinAreaWidthcomputeChildMinAreaWidthcomputeChildPrefAreaHeightcomputeChildPrefAreaHeightcomputeChildPrefAreaWidthcomputeChildPrefAreaWidthcomputeMaxHeightcomputeMaxMinAreaHeightcomputeMaxMinAreaHeightcomputeMaxMinAreaHeightcomputeMaxMinAreaWidthcomputeMaxMinAreaWidthcomputeMaxMinAreaWidthcomputeMaxPrefAreaHeightcomputeMaxPrefAreaHeightcomputeMaxPrefAreaHeightcomputeMaxPrefAreaWidthcomputeMaxPrefAreaWidthcomputeMaxPrefAreaWidthcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcomputeXOffsetcomputeYOffsetcreateDoubleArraygetAreaBaselineOffsetgetAreaBaselineOffsetgetAreaBaselineOffsetgetAreaBaselineOffsetgetAreaBaselineOffsetgetAreaBaselineOffsetgetBackgroundgetBordergetClassCssMetaDatagetCssMetaDatagetHeightgetInsetsgetMaxBaselineComplementgetMaxHeightgetMaxWidthgetMinBaselineComplementgetMinHeightgetMinWidthgetOpaqueInsetsgetPaddinggetPrefBaselineComplementgetPrefHeightgetPrefWidthgetShapegetSnapScaleXgetSnapScaleYgetUserAgentStylesheetgetWidthheightPropertyinsetsPropertyisCacheShapeisCenterShapeisResizableisScaleShapeisSnapToPixellayoutInArealayoutInArealayoutInArealayoutInAreamaxHeightmaxHeightPropertymaxWidthmaxWidthPropertyminHeightminHeightPropertyminWidthminWidthPropertyopaqueInsetsPropertypaddingPropertypositionInAreapositionInAreaprefHeightprefHeightPropertyprefWidthprefWidthPropertyremoveImageListenerresizescaleShapePropertysetBackgroundsetBordersetCacheShapesetCenterShapesetHeightsetMaxHeightsetMaxSizesetMaxWidthsetMinHeightsetMinSizesetMinWidthsetOpaqueInsetssetPaddingsetPrefHeightsetPrefSizesetPrefWidthsetScaleShapesetShapesetSnapToPixelsetWidthshapePropertysnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPortionXsnapPortionYsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYsnapToPixelPropertywidthProperty

Constructor Detail

Paneback to summary
public Pane()

Creates a Pane layout.

Paneback to summary
public Pane(Node... children)

Creates a Pane layout.

Parameters
children:Node[]

The initial set of children for this pane.

Since
JavaFX 8.0

Method Detail

getChildrenback to summary
public ObservableList<Node> getChildren()

Overrides javafx.scene.Parent.getChildren.

Doc from javafx.scene.Parent.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 (javafx.stage.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:ObservableList<Node>

modifiable list of children.

Annotations
@Override
getConstraintback to summary
pack-priv static Object getConstraint(Node node, Object key)
setConstraintback to summary
pack-priv static void setConstraint(Node node, Object key, Object value)