GridPane
.
If a RowConstraints object is added for a row in a gridpane, the gridpane
will use those constraint values when computing the row's height and layout.
For example, to create a GridPane with 10 rows 50 pixels tall:
GridPane gridpane = new GridPane();
for (int i = 0; i < 10; i++) {
RowConstraints row = new RowConstraints(50);
gridpane.getRowConstraints().add(row);
}
Or, to create a GridPane where rows take 25%, 50%, 25% of its height:
GridPane gridpane = new GridPane();
RowConstraints row1 = new RowConstraints();
row1.setPercentHeight(25);
RowConstraints row2 = new RowConstraints();
row2.setPercentHeight(50);
RowConstraints row3 = new RowConstraints();
row3.setPercentHeight(25);
gridpane.getRowConstraints().addAll(row1,row2,row3);
Note that adding an empty RowConstraints object has the effect of not setting
any constraints, leaving the GridPane to compute the row's layout based
solely on its content's size preferences and constraints.- Since:
- JavaFX 2.0
-
Property Summary
TypePropertyDescriptionfinal BooleanProperty
The vertical fill policy for the row.final DoubleProperty
The maximum height for the row.final DoubleProperty
The minimum height for the row.final DoubleProperty
The height percentage of the row.final DoubleProperty
The preferred height for the row.final ObjectProperty<VPos>
The vertical alignment for the row.final ObjectProperty<Priority>
The vertical grow priority for the row. -
Field Summary
Fields declared in class javafx.scene.layout.ConstraintsBase
CONSTRAIN_TO_PREF
-
Constructor Summary
ConstructorDescriptionCreates a row constraints object with no properties set.RowConstraints
(double height) Creates a row constraint object with a fixed height.RowConstraints
(double minHeight, double prefHeight, double maxHeight) Creates a row constraint object with a fixed size range.RowConstraints
(double minHeight, double prefHeight, double maxHeight, Priority vgrow, VPos valignment, boolean fillHeight) Creates a row constraint object with a fixed size range, vertical grow priority, vertical alignment, and vertical fill behavior. -
Method Summary
Modifier and TypeMethodDescriptionfinal BooleanProperty
The vertical fill policy for the row.final double
Gets the value of themaxHeight
property.final double
Gets the value of theminHeight
property.final double
Gets the value of thepercentHeight
property.final double
Gets the value of theprefHeight
property.final VPos
Gets the value of thevalignment
property.final Priority
getVgrow()
Gets the value of thevgrow
property.final boolean
Gets the value of thefillHeight
property.final DoubleProperty
The maximum height for the row.final DoubleProperty
The minimum height for the row.final DoubleProperty
The height percentage of the row.final DoubleProperty
The preferred height for the row.final void
setFillHeight
(boolean value) Sets the value of thefillHeight
property.final void
setMaxHeight
(double value) Sets the value of themaxHeight
property.final void
setMinHeight
(double value) Sets the value of theminHeight
property.final void
setPercentHeight
(double value) Sets the value of thepercentHeight
property.final void
setPrefHeight
(double value) Sets the value of theprefHeight
property.final void
setValignment
(VPos value) Sets the value of thevalignment
property.final void
Sets the value of thevgrow
property.toString()
Returns a string representation of thisRowConstraints
object.final ObjectProperty<VPos>
The vertical alignment for the row.final ObjectProperty<Priority>
The vertical grow priority for the row.Methods declared in class javafx.scene.layout.ConstraintsBase
requestLayout
-
Property Details
-
minHeight
The minimum height for the row. This property is ignored if percentHeight is set.The default value is USE_COMPUTED_SIZE, which means the minimum height will be computed to be the largest minimum height of the row's content.
-
prefHeight
The preferred height for the row. This property is ignored if percentHeight is set.The default value is USE_COMPUTED_SIZE, which means the preferred height will be computed to be the largest preferred height of the row's content.
-
maxHeight
The maximum height for the row. This property is ignored if percentHeight is set.The default value is USE_COMPUTED_SIZE, which means the maximum height will be computed to be the smallest maximum height of the row's content.
-
percentHeight
The height percentage of the row. If set to a value greater than 0, the row will be resized to that percentage of the available gridpane height and the other size constraints (minHeight, prefHeight, maxHeight, vgrow) will be ignored. The default value is -1, which means the percentage will be ignored. -
vgrow
The vertical grow priority for the row. If set, the gridpane will use this priority to determine whether the row should be given any additional height if the gridpane is resized larger than its preferred height. This property is ignored if percentHeight is set.This default value is null, which means that the row's grow priority will be derived from largest grow priority set on a content node.
- See Also:
-
valignment
The vertical alignment for the row. If set, will be the default vertical alignment for nodes contained within the row. If this property is set to VPos.BASELINE, then the fillHeight property will be ignored and nodes will always be resized to their preferred heights. -
fillHeight
The vertical fill policy for the row. The gridpane will use this property to determine whether nodes contained within the row should be expanded to fill the row's height or kept to their preferred heights.The default value is true.
-
-
Constructor Details
-
RowConstraints
public RowConstraints()Creates a row constraints object with no properties set. -
RowConstraints
public RowConstraints(double height) Creates a row constraint object with a fixed height. This is a convenience for setting the preferred height constraint to the fixed value and the minHeight and maxHeight constraints to the USE_PREF_SIZE flag to ensure the row is always that height.- Parameters:
height
- the height of the row
-
RowConstraints
public RowConstraints(double minHeight, double prefHeight, double maxHeight) Creates a row constraint object with a fixed size range. This is a convenience for setting the minimum, preferred, and maximum height constraints.- Parameters:
minHeight
- the minimum heightprefHeight
- the preferred heightmaxHeight
- the maximum height
-
RowConstraints
public RowConstraints(double minHeight, double prefHeight, double maxHeight, Priority vgrow, VPos valignment, boolean fillHeight) Creates a row constraint object with a fixed size range, vertical grow priority, vertical alignment, and vertical fill behavior.- Parameters:
minHeight
- the minimum heightprefHeight
- the preferred heightmaxHeight
- the maximum heightvgrow
- the vertical grow priorityvalignment
- the vertical alignmentfillHeight
- the vertical fill behavior
-
-
Method Details
-
setMinHeight
public final void setMinHeight(double value) Sets the value of theminHeight
property.- Property description:
- The minimum height for the row.
This property is ignored if percentHeight is set.
The default value is USE_COMPUTED_SIZE, which means the minimum height will be computed to be the largest minimum height of the row's content.
- Parameters:
value
- the value for theminHeight
property- See Also:
-
getMinHeight
public final double getMinHeight()Gets the value of theminHeight
property.- Property description:
- The minimum height for the row.
This property is ignored if percentHeight is set.
The default value is USE_COMPUTED_SIZE, which means the minimum height will be computed to be the largest minimum height of the row's content.
- Returns:
- the value of the
minHeight
property - See Also:
-
minHeightProperty
The minimum height for the row. This property is ignored if percentHeight is set.The default value is USE_COMPUTED_SIZE, which means the minimum height will be computed to be the largest minimum height of the row's content.
- Returns:
- the
minHeight
property - See Also:
-
setPrefHeight
public final void setPrefHeight(double value) Sets the value of theprefHeight
property.- Property description:
- The preferred height for the row.
This property is ignored if percentHeight is set.
The default value is USE_COMPUTED_SIZE, which means the preferred height will be computed to be the largest preferred height of the row's content.
- Parameters:
value
- the value for theprefHeight
property- See Also:
-
getPrefHeight
public final double getPrefHeight()Gets the value of theprefHeight
property.- Property description:
- The preferred height for the row.
This property is ignored if percentHeight is set.
The default value is USE_COMPUTED_SIZE, which means the preferred height will be computed to be the largest preferred height of the row's content.
- Returns:
- the value of the
prefHeight
property - See Also:
-
prefHeightProperty
The preferred height for the row. This property is ignored if percentHeight is set.The default value is USE_COMPUTED_SIZE, which means the preferred height will be computed to be the largest preferred height of the row's content.
- Returns:
- the
prefHeight
property - See Also:
-
setMaxHeight
public final void setMaxHeight(double value) Sets the value of themaxHeight
property.- Property description:
- The maximum height for the row.
This property is ignored if percentHeight is set.
The default value is USE_COMPUTED_SIZE, which means the maximum height will be computed to be the smallest maximum height of the row's content.
- Parameters:
value
- the value for themaxHeight
property- See Also:
-
getMaxHeight
public final double getMaxHeight()Gets the value of themaxHeight
property.- Property description:
- The maximum height for the row.
This property is ignored if percentHeight is set.
The default value is USE_COMPUTED_SIZE, which means the maximum height will be computed to be the smallest maximum height of the row's content.
- Returns:
- the value of the
maxHeight
property - See Also:
-
maxHeightProperty
The maximum height for the row. This property is ignored if percentHeight is set.The default value is USE_COMPUTED_SIZE, which means the maximum height will be computed to be the smallest maximum height of the row's content.
- Returns:
- the
maxHeight
property - See Also:
-
setPercentHeight
public final void setPercentHeight(double value) Sets the value of thepercentHeight
property.- Property description:
- The height percentage of the row. If set to a value greater than 0, the row will be resized to that percentage of the available gridpane height and the other size constraints (minHeight, prefHeight, maxHeight, vgrow) will be ignored. The default value is -1, which means the percentage will be ignored.
- Parameters:
value
- the value for thepercentHeight
property- See Also:
-
getPercentHeight
public final double getPercentHeight()Gets the value of thepercentHeight
property.- Property description:
- The height percentage of the row. If set to a value greater than 0, the row will be resized to that percentage of the available gridpane height and the other size constraints (minHeight, prefHeight, maxHeight, vgrow) will be ignored. The default value is -1, which means the percentage will be ignored.
- Returns:
- the value of the
percentHeight
property - See Also:
-
percentHeightProperty
The height percentage of the row. If set to a value greater than 0, the row will be resized to that percentage of the available gridpane height and the other size constraints (minHeight, prefHeight, maxHeight, vgrow) will be ignored. The default value is -1, which means the percentage will be ignored.- Returns:
- the
percentHeight
property - See Also:
-
setVgrow
Sets the value of thevgrow
property.- Property description:
- The vertical grow priority for the row. If set, the gridpane will
use this priority to determine whether the row should be given any
additional height if the gridpane is resized larger than its preferred height.
This property is ignored if percentHeight is set.
This default value is null, which means that the row's grow priority will be derived from largest grow priority set on a content node.
- Parameters:
value
- the value for thevgrow
property- See Also:
-
getVgrow
Gets the value of thevgrow
property.- Property description:
- The vertical grow priority for the row. If set, the gridpane will
use this priority to determine whether the row should be given any
additional height if the gridpane is resized larger than its preferred height.
This property is ignored if percentHeight is set.
This default value is null, which means that the row's grow priority will be derived from largest grow priority set on a content node.
- Returns:
- the value of the
vgrow
property - See Also:
-
vgrowProperty
The vertical grow priority for the row. If set, the gridpane will use this priority to determine whether the row should be given any additional height if the gridpane is resized larger than its preferred height. This property is ignored if percentHeight is set.This default value is null, which means that the row's grow priority will be derived from largest grow priority set on a content node.
- Returns:
- the
vgrow
property - See Also:
-
setValignment
Sets the value of thevalignment
property.- Property description:
- The vertical alignment for the row. If set, will be the default vertical alignment for nodes contained within the row. If this property is set to VPos.BASELINE, then the fillHeight property will be ignored and nodes will always be resized to their preferred heights.
- Parameters:
value
- the value for thevalignment
property- See Also:
-
getValignment
Gets the value of thevalignment
property.- Property description:
- The vertical alignment for the row. If set, will be the default vertical alignment for nodes contained within the row. If this property is set to VPos.BASELINE, then the fillHeight property will be ignored and nodes will always be resized to their preferred heights.
- Returns:
- the value of the
valignment
property - See Also:
-
valignmentProperty
The vertical alignment for the row. If set, will be the default vertical alignment for nodes contained within the row. If this property is set to VPos.BASELINE, then the fillHeight property will be ignored and nodes will always be resized to their preferred heights.- Returns:
- the
valignment
property - See Also:
-
setFillHeight
public final void setFillHeight(boolean value) Sets the value of thefillHeight
property.- Property description:
- The vertical fill policy for the row. The gridpane will
use this property to determine whether nodes contained within the row
should be expanded to fill the row's height or kept to their preferred heights.
The default value is true.
- Parameters:
value
- the value for thefillHeight
property- See Also:
-
isFillHeight
public final boolean isFillHeight()Gets the value of thefillHeight
property.- Property description:
- The vertical fill policy for the row. The gridpane will
use this property to determine whether nodes contained within the row
should be expanded to fill the row's height or kept to their preferred heights.
The default value is true.
- Returns:
- the value of the
fillHeight
property - See Also:
-
fillHeightProperty
The vertical fill policy for the row. The gridpane will use this property to determine whether nodes contained within the row should be expanded to fill the row's height or kept to their preferred heights.The default value is true.
- Returns:
- the
fillHeight
property - See Also:
-
toString
Returns a string representation of thisRowConstraints
object.
-