31 import javafx.beans.property.ObjectProperty;
32 import javafx.css.CssMetaData;
33 import javafx.css.StyleableObjectProperty;
34 import javafx.css.StyleableProperty;
35 import javafx.geometry.Insets;
36 import javafx.geometry.Orientation;
37 import javafx.geometry.Pos;
38 import javafx.geometry.VPos;
39 import javafx.scene.Node;
40 import javafx.css.converter.EnumConverter;
41 import javafx.css.Styleable;
42 import javafx.geometry.HPos;
43 import javafx.util.Callback;
44
45 /**
46 *
47 * StackPane lays out its children in a back-to-front stack.
48 * <p>
49 * The z-order of the children is defined by the order of the children list
50 * with the 0th child being the bottom and last child on top. If a border and/or
51 * padding have been set, the children will be layed out within those insets.
52 * <p>
53 * The stackpane will attempt to resize each child to fill its content area.
54 * If the child could not be sized to fill the stackpane (either because it was
55 * not resizable or its max size prevented it) then it will be aligned within
56 * the area using the alignment property, which defaults to Pos.CENTER.
57 * <p>
58 * StackPane example:
59 * <pre>{@code StackPane stack = new StackPane();
60 * stack.getChildren().addAll(new Rectangle(100,100,Color.BLUE), new Label("Go!));
61 * }</pre>
62 * <p>
63 * StackPane lays out each managed child regardless of the child's
64 * visible property value; unmanaged children are ignored.</p>
65 * <p>
66 * StackPane may be styled with backgrounds and borders using CSS. See
67 * {@link javafx.scene.layout.Region Region} for details.</p>
68 *
69 * <h3>Resizable Range</h3>
70 *
71 * <p>
72 * A stackpane's parent will resize the stackpane within the stackpane's resizable range
73 * during layout. By default the stackpane computes this range based on its content
74 * as outlined in the table below.
75 * </p>
76 *
77 * <table border="1">
78 * <caption>StackPane Resize Table</caption>
79 * <tr><td></td><th scope="col">width</th><th scope="col">height</th></tr>
84 * <td>left/right insets plus the largest of the children's pref widths.</td>
85 * <td>top/bottom insets plus the largest of the children's pref heights.</td></tr>
86 * <tr><th scope="row">maximum</th>
87 * <td>Double.MAX_VALUE</td><td>Double.MAX_VALUE</td></tr>
88 * </table>
89 * <p>
90 * A stackpane's unbounded maximum width and height are an indication to the parent that
91 * it may be resized beyond its preferred size to fill whatever space is assigned
92 * to it.
93 * <p>
94 * StackPane provides properties for setting the size range directly. These
95 * properties default to the sentinel value USE_COMPUTED_SIZE, however the
96 * application may set them to other values as needed:
97 * <pre><code> // ensure stackpane is never resized beyond it's preferred size
98 * <b>stackpane.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);</b>
99 * </code></pre>
100 * Applications may restore the computed values by setting these properties back
101 * to USE_COMPUTED_SIZE.
102 *
103 * <p>
104 * StackPane does not clip its content by default, so it is possible that childrens'
105 * bounds may extend outside its own bounds if a child's min size prevents it from
106 * being fit within the stackpane.</p>
107 *
108 * <h3>Optional Layout Constraints</h3>
109 *
110 * <p>
111 * An application may set constraints on individual children to customize StackPane's layout.
112 * For each constraint, StackPane provides a static method for setting it on the child.
113 * </p>
114 *
115 * <table border="1">
116 * <caption>StackPane Constraint Table</caption>
117 * <tr><th>Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
118 * <tr><th scope="row">alignment</th><td>javafx.geometry.Pos</td><td>The alignment of the child within the stackpane.</td></tr>
119 * <tr><th scope="row">margin</th><td>javafx.geometry.Insets</td><td>Margin space around the outside of the child.</td></tr>
120 * </table>
121 * <p>
122 * Examples:
123 * <pre><code> // Align the title Label at the bottom-center of the stackpane
124 * Label title = new Label();
|
31 import javafx.beans.property.ObjectProperty;
32 import javafx.css.CssMetaData;
33 import javafx.css.StyleableObjectProperty;
34 import javafx.css.StyleableProperty;
35 import javafx.geometry.Insets;
36 import javafx.geometry.Orientation;
37 import javafx.geometry.Pos;
38 import javafx.geometry.VPos;
39 import javafx.scene.Node;
40 import javafx.css.converter.EnumConverter;
41 import javafx.css.Styleable;
42 import javafx.geometry.HPos;
43 import javafx.util.Callback;
44
45 /**
46 *
47 * StackPane lays out its children in a back-to-front stack.
48 * <p>
49 * The z-order of the children is defined by the order of the children list
50 * with the 0th child being the bottom and last child on top. If a border and/or
51 * padding have been set, the children will be laid out within those insets.
52 * <p>
53 * The stackpane will attempt to resize each child to fill its content area.
54 * If the child could not be sized to fill the stackpane (either because it was
55 * not resizable or its max size prevented it) then it will be aligned within
56 * the area using the alignment property, which defaults to Pos.CENTER.
57 * <p>
58 * StackPane example:
59 * <pre>{@code
60 * StackPane stack = new StackPane();
61 * stack.getChildren().addAll(new Rectangle(100,100,Color.BLUE), new Label("Go!));
62 * }</pre>
63 * <p>
64 * StackPane lays out each managed child regardless of the child's
65 * visible property value; unmanaged children are ignored.</p>
66 * <p>
67 * StackPane may be styled with backgrounds and borders using CSS. See
68 * {@link javafx.scene.layout.Region Region} for details.</p>
69 *
70 * <h3>Resizable Range</h3>
71 *
72 * <p>
73 * A stackpane's parent will resize the stackpane within the stackpane's resizable range
74 * during layout. By default the stackpane computes this range based on its content
75 * as outlined in the table below.
76 * </p>
77 *
78 * <table border="1">
79 * <caption>StackPane Resize Table</caption>
80 * <tr><td></td><th scope="col">width</th><th scope="col">height</th></tr>
85 * <td>left/right insets plus the largest of the children's pref widths.</td>
86 * <td>top/bottom insets plus the largest of the children's pref heights.</td></tr>
87 * <tr><th scope="row">maximum</th>
88 * <td>Double.MAX_VALUE</td><td>Double.MAX_VALUE</td></tr>
89 * </table>
90 * <p>
91 * A stackpane's unbounded maximum width and height are an indication to the parent that
92 * it may be resized beyond its preferred size to fill whatever space is assigned
93 * to it.
94 * <p>
95 * StackPane provides properties for setting the size range directly. These
96 * properties default to the sentinel value USE_COMPUTED_SIZE, however the
97 * application may set them to other values as needed:
98 * <pre><code> // ensure stackpane is never resized beyond it's preferred size
99 * <b>stackpane.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);</b>
100 * </code></pre>
101 * Applications may restore the computed values by setting these properties back
102 * to USE_COMPUTED_SIZE.
103 *
104 * <p>
105 * StackPane does not clip its content by default, so it is possible that children's
106 * bounds may extend outside its own bounds if a child's min size prevents it from
107 * being fit within the stackpane.</p>
108 *
109 * <h3>Optional Layout Constraints</h3>
110 *
111 * <p>
112 * An application may set constraints on individual children to customize StackPane's layout.
113 * For each constraint, StackPane provides a static method for setting it on the child.
114 * </p>
115 *
116 * <table border="1">
117 * <caption>StackPane Constraint Table</caption>
118 * <tr><th>Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
119 * <tr><th scope="row">alignment</th><td>javafx.geometry.Pos</td><td>The alignment of the child within the stackpane.</td></tr>
120 * <tr><th scope="row">margin</th><td>javafx.geometry.Insets</td><td>Margin space around the outside of the child.</td></tr>
121 * </table>
122 * <p>
123 * Examples:
124 * <pre><code> // Align the title Label at the bottom-center of the stackpane
125 * Label title = new Label();
|