33 import javafx.beans.property.ObjectProperty;
34 import javafx.css.CssMetaData;
35 import javafx.css.StyleableBooleanProperty;
36 import javafx.css.StyleableDoubleProperty;
37 import javafx.css.StyleableObjectProperty;
38 import javafx.css.StyleableProperty;
39 import javafx.geometry.HPos;
40 import javafx.geometry.Insets;
41 import javafx.geometry.Orientation;
42 import javafx.geometry.Pos;
43 import javafx.geometry.VPos;
44 import javafx.scene.Node;
45 import javafx.css.converter.BooleanConverter;
46 import javafx.css.converter.EnumConverter;
47 import javafx.css.converter.SizeConverter;
48 import javafx.css.Styleable;
49 import javafx.util.Callback;
50
51 /**
52 * VBox lays out its children in a single vertical column.
53 * If the vbox has a border and/or padding set, then the contents will be layed
54 * out within those insets.
55 * <p>
56 * VBox example:
57 * <pre>{@code
58 * VBox vbox = new VBox(8); // spacing = 8
59 * vbox.getChildren().addAll(new Button("Cut"), new Button("Copy"), new Button("Paste"));
60 * }</pre>
61 *
62 * VBox will resize children (if resizable) to their preferred heights and uses its
63 * {@link #fillWidthProperty() fillWidth} property to determine whether to resize their widths to
64 * fill its own width or keep their widths to their preferred (fillWidth defaults to true).
65 * The alignment of the content is controlled by the {@link #alignmentProperty() alignment} property,
66 * which defaults to Pos.TOP_LEFT.
67 * <p>
68 * If a vbox is resized larger than its preferred height, by default it will keep
69 * children to their preferred heights, leaving the extra space unused. If an
70 * application wishes to have one or more children be allocated that extra space
71 * it may optionally set a vgrow constraint on the child. See "Optional Layout
72 * Constraints" for details.
73 * <p>
92 * <td>left/right insets plus the largest of the children's pref widths.</td>
93 * <td>top/bottom insets plus the sum of each child's pref height plus spacing between each child.</td>
94 * </tr>
95 * <tr><th scope="row">maximum</th>
96 * <td>Double.MAX_VALUE</td><td>Double.MAX_VALUE</td></tr>
97 * </table>
98 * <p>
99 * A vbox's unbounded maximum width and height are an indication to the parent that
100 * it may be resized beyond its preferred size to fill whatever space is assigned
101 * to it.
102 * <p>
103 * VBox provides properties for setting the size range directly. These
104 * properties default to the sentinel value USE_COMPUTED_SIZE, however the
105 * application may set them to other values as needed:
106 * <pre><code>
107 * <b>vbox.setPrefWidth(400);</b>
108 * </code></pre>
109 * Applications may restore the computed values by setting these properties back
110 * to USE_COMPUTED_SIZE.
111 * <p>
112 * VBox does not clip its content by default, so it is possible that childrens'
113 * bounds may extend outside its own bounds if a child's min size prevents it from
114 * being fit within the vbox.</p>
115 *
116 * <h3>Optional Layout Constraints</h3>
117 *
118 * <p>
119 * An application may set constraints on individual children to customize VBox's layout.
120 * For each constraint, VBox provides a static method for setting it on the child.
121 * </p>
122 *
123 * <table border="1">
124 * <caption>VBox Constraint Table</caption>
125 * <tr><th scope="col">Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
126 * <tr><th scope="row">vgrow</th><td>javafx.scene.layout.Priority</td><td>The vertical grow priority for the child.</td></tr>
127 * <tr><th scope="row">margin</th><td>javafx.geometry.Insets</td><td>Margin space around the outside of the child.</td></tr>
128 * </table>
129 * <p>
130 * For example, if a vbox needs the ListView to be allocated all extra space:
131 * <pre><code>
132 * VBox vbox = new VBox();
|
33 import javafx.beans.property.ObjectProperty;
34 import javafx.css.CssMetaData;
35 import javafx.css.StyleableBooleanProperty;
36 import javafx.css.StyleableDoubleProperty;
37 import javafx.css.StyleableObjectProperty;
38 import javafx.css.StyleableProperty;
39 import javafx.geometry.HPos;
40 import javafx.geometry.Insets;
41 import javafx.geometry.Orientation;
42 import javafx.geometry.Pos;
43 import javafx.geometry.VPos;
44 import javafx.scene.Node;
45 import javafx.css.converter.BooleanConverter;
46 import javafx.css.converter.EnumConverter;
47 import javafx.css.converter.SizeConverter;
48 import javafx.css.Styleable;
49 import javafx.util.Callback;
50
51 /**
52 * VBox lays out its children in a single vertical column.
53 * If the vbox has a border and/or padding set, then the contents will be laid
54 * out within those insets.
55 * <p>
56 * VBox example:
57 * <pre>{@code
58 * VBox vbox = new VBox(8); // spacing = 8
59 * vbox.getChildren().addAll(new Button("Cut"), new Button("Copy"), new Button("Paste"));
60 * }</pre>
61 *
62 * VBox will resize children (if resizable) to their preferred heights and uses its
63 * {@link #fillWidthProperty() fillWidth} property to determine whether to resize their widths to
64 * fill its own width or keep their widths to their preferred (fillWidth defaults to true).
65 * The alignment of the content is controlled by the {@link #alignmentProperty() alignment} property,
66 * which defaults to Pos.TOP_LEFT.
67 * <p>
68 * If a vbox is resized larger than its preferred height, by default it will keep
69 * children to their preferred heights, leaving the extra space unused. If an
70 * application wishes to have one or more children be allocated that extra space
71 * it may optionally set a vgrow constraint on the child. See "Optional Layout
72 * Constraints" for details.
73 * <p>
92 * <td>left/right insets plus the largest of the children's pref widths.</td>
93 * <td>top/bottom insets plus the sum of each child's pref height plus spacing between each child.</td>
94 * </tr>
95 * <tr><th scope="row">maximum</th>
96 * <td>Double.MAX_VALUE</td><td>Double.MAX_VALUE</td></tr>
97 * </table>
98 * <p>
99 * A vbox's unbounded maximum width and height are an indication to the parent that
100 * it may be resized beyond its preferred size to fill whatever space is assigned
101 * to it.
102 * <p>
103 * VBox provides properties for setting the size range directly. These
104 * properties default to the sentinel value USE_COMPUTED_SIZE, however the
105 * application may set them to other values as needed:
106 * <pre><code>
107 * <b>vbox.setPrefWidth(400);</b>
108 * </code></pre>
109 * Applications may restore the computed values by setting these properties back
110 * to USE_COMPUTED_SIZE.
111 * <p>
112 * VBox does not clip its content by default, so it is possible that children's
113 * bounds may extend outside its own bounds if a child's min size prevents it from
114 * being fit within the vbox.</p>
115 *
116 * <h3>Optional Layout Constraints</h3>
117 *
118 * <p>
119 * An application may set constraints on individual children to customize VBox's layout.
120 * For each constraint, VBox provides a static method for setting it on the child.
121 * </p>
122 *
123 * <table border="1">
124 * <caption>VBox Constraint Table</caption>
125 * <tr><th scope="col">Constraint</th><th scope="col">Type</th><th scope="col">Description</th></tr>
126 * <tr><th scope="row">vgrow</th><td>javafx.scene.layout.Priority</td><td>The vertical grow priority for the child.</td></tr>
127 * <tr><th scope="row">margin</th><td>javafx.geometry.Insets</td><td>Margin space around the outside of the child.</td></tr>
128 * </table>
129 * <p>
130 * For example, if a vbox needs the ListView to be allocated all extra space:
131 * <pre><code>
132 * VBox vbox = new VBox();
|