/* * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.scene.layout; import javafx.beans.DefaultProperty; import javafx.collections.ObservableList; import 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 {@link javafx.scene.layout.StackPane 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 tables below: * * * * * * * * * * * *
widthheight
minimumleft plus right insets.top plus bottom insets.
preferredwidth 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.
maximumDouble.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 childrens' * 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 */ @DefaultProperty("children") public class Pane extends Region { static void setConstraint(Node node, Object key, Object value) { if (value == null) { node.getProperties().remove(key); } else { node.getProperties().put(key, value); } if (node.getParent() != null) { node.getParent().requestLayout(); } } static Object getConstraint(Node node, Object key) { if (node.hasProperties()) { Object value = node.getProperties().get(key); if (value != null) { return value; } } return null; } /** * Creates a Pane layout. */ public Pane() { super(); } /** * Creates a Pane layout. * @param children The initial set of children for this pane. * @since JavaFX 8.0 */ public Pane(Node... children) { super(); getChildren().addAll(children); } /** * * @return modifiable list of children. */ @Override public ObservableList getChildren() { return super.getChildren(); } }