public class Pane extends Region
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.
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:
width | height | |
---|---|---|
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_VALUE | Double.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.
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthProperty
TEMP_VEC2D, USE_COMPUTED_SIZE, USE_PREF_SIZE
Constructor and Description |
---|
Pane()
Creates a Pane layout.
|
Pane(Node... children)
Creates a Pane layout.
|
Modifier and Type | Method and Description |
---|---|
<any> |
getChildren() |
(package private) static java.lang.Object |
getConstraint(Node node,
java.lang.Object key) |
(package private) static void |
setConstraint(Node node,
java.lang.Object key,
java.lang.Object value) |
addImageListener, adjustHeightByMargin, adjustWidthByMargin, backgroundProperty, borderProperty, boundedNodeSizeWithBias, boundedSize, cacheShapeProperty, centerShapeProperty, computeChildMaxAreaHeight, computeChildMaxAreaWidth, computeChildMinAreaHeight, computeChildMinAreaHeight, computeChildMinAreaWidth, computeChildMinAreaWidth, computeChildPrefAreaHeight, computeChildPrefAreaHeight, computeChildPrefAreaWidth, computeChildPrefAreaWidth, computeMaxHeight, computeMaxMinAreaHeight, computeMaxMinAreaHeight, computeMaxMinAreaHeight, computeMaxMinAreaWidth, computeMaxMinAreaWidth, computeMaxMinAreaWidth, computeMaxPrefAreaHeight, computeMaxPrefAreaHeight, computeMaxPrefAreaHeight, computeMaxPrefAreaWidth, computeMaxPrefAreaWidth, computeMaxPrefAreaWidth, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, computeXOffset, computeYOffset, createDoubleArray, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxBaselineComplement, getMaxHeight, getMaxWidth, getMinBaselineComplement, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefBaselineComplement, 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, removeImageListener, 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, snapPortionX, snapPortionY, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty