Class RowConstraints
public class RowConstraints extends ConstraintsBase
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
| Type | Property | Description |
|---|---|---|
final BooleanProperty |
fillHeight |
The vertical fill policy for the row. |
final DoubleProperty |
maxHeight |
The maximum height for the row. |
final DoubleProperty |
minHeight |
The minimum height for the row. |
final DoubleProperty |
percentHeight |
The height percentage of the row. |
final DoubleProperty |
prefHeight |
The preferred height for the row. |
final ObjectProperty |
valignment |
The vertical alignment for the row. |
final ObjectProperty |
vgrow |
The vertical grow priority for the row. |
Field Summary
Fields declared in class javafx.scene.layout.ConstraintsBase
CONSTRAIN_TO_PREF
Constructor Summary
| Constructor | Description |
|---|---|
RowConstraints() |
Creates a row constraints object with no properties set. |
RowConstraints |
Creates a row constraint object with a fixed height. |
RowConstraints |
Creates a row constraint object with a fixed size range. |
RowConstraints |
Creates a row constraint object with a fixed size range, vertical grow priority, vertical alignment, and vertical fill behavior. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
final BooleanProperty |
fillHeightProperty() |
The vertical fill policy for the row. |
final double |
getMaxHeight() |
Gets the value of the maxHeight property. |
final double |
getMinHeight() |
Gets the value of the minHeight property. |
final double |
getPercentHeight() |
Gets the value of the percentHeight property. |
final double |
getPrefHeight() |
Gets the value of the prefHeight property. |
final VPos |
getValignment() |
Gets the value of the valignment property. |
final Priority |
getVgrow() |
Gets the value of the vgrow property. |
final boolean |
isFillHeight() |
Gets the value of the fillHeight property. |
final DoubleProperty |
maxHeightProperty() |
The maximum height for the row. |
final DoubleProperty |
minHeightProperty() |
The minimum height for the row. |
final DoubleProperty |
percentHeightProperty() |
The height percentage of the row. |
final DoubleProperty |
prefHeightProperty() |
The preferred height for the row. |
final void |
setFillHeight |
Sets the value of the fillHeight property. |
final void |
setMaxHeight |
Sets the value of the maxHeight property. |
final void |
setMinHeight |
Sets the value of the minHeight property. |
final void |
setPercentHeight |
Sets the value of the percentHeight property. |
final void |
setPrefHeight |
Sets the value of the prefHeight property. |
final void |
setValignment |
Sets the value of the valignment property. |
final void |
setVgrow |
Sets the value of the vgrow property. |
String |
toString() |
Returns a string representation of this RowConstraints object. |
final ObjectProperty |
valignmentProperty() |
The vertical alignment for the row. |
final ObjectProperty |
vgrowProperty() |
The vertical grow priority for the row. |
Methods declared in class javafx.scene.layout.ConstraintsBase
requestLayout
Property Details
minHeight
public final DoubleProperty minHeightProperty
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.
- See Also:
prefHeight
public final DoubleProperty prefHeightProperty
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.
- See Also:
maxHeight
public final DoubleProperty maxHeightProperty
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.
- See Also:
percentHeight
public final DoubleProperty percentHeightProperty
- See Also:
vgrow
public final ObjectProperty<Priority> vgrowProperty
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
public final ObjectProperty<VPos> valignmentProperty
- See Also:
fillHeight
public final BooleanProperty fillHeightProperty
The default value is true.
- See Also:
Constructor Details
RowConstraints
public RowConstraints()
RowConstraints
public RowConstraints(double height)
- Parameters:
-
height- the height of the row
RowConstraints
public RowConstraints(double minHeight, double prefHeight, double maxHeight)
- Parameters:
-
minHeight- the minimum height -
prefHeight- the preferred height -
maxHeight- the maximum height
RowConstraints
public RowConstraints(double minHeight, double prefHeight, double maxHeight, Priority vgrow, VPos valignment, boolean fillHeight)
- Parameters:
-
minHeight- the minimum height -
prefHeight- the preferred height -
maxHeight- the maximum height -
vgrow- the vertical grow priority -
valignment- the vertical alignment -
fillHeight- the vertical fill behavior
Method Details
setMinHeight
public final void setMinHeight(double value)
minHeight 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 theminHeightproperty - See Also:
getMinHeight
public final double getMinHeight()
minHeight 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
minHeightproperty - See Also:
minHeightProperty
public final DoubleProperty minHeightProperty()
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
minHeightproperty - See Also:
setPrefHeight
public final void setPrefHeight(double value)
prefHeight 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 theprefHeightproperty - See Also:
getPrefHeight
public final double getPrefHeight()
prefHeight 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
prefHeightproperty - See Also:
prefHeightProperty
public final DoubleProperty prefHeightProperty()
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
prefHeightproperty - See Also:
setMaxHeight
public final void setMaxHeight(double value)
maxHeight 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 themaxHeightproperty - See Also:
getMaxHeight
public final double getMaxHeight()
maxHeight 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
maxHeightproperty - See Also:
maxHeightProperty
public final DoubleProperty maxHeightProperty()
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
maxHeightproperty - See Also:
setPercentHeight
public final void setPercentHeight(double value)
percentHeight 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 thepercentHeightproperty - See Also:
getPercentHeight
public final double getPercentHeight()
percentHeight 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
percentHeightproperty - See Also:
percentHeightProperty
public final DoubleProperty percentHeightProperty()
- Returns:
- the
percentHeightproperty - See Also:
setVgrow
public final void setVgrow(Priority value)
vgrow 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 thevgrowproperty - See Also:
getVgrow
public final Priority getVgrow()
vgrow 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
vgrowproperty - See Also:
vgrowProperty
public final ObjectProperty<Priority> vgrowProperty()
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
vgrowproperty - See Also:
setValignment
public final void setValignment(VPos value)
valignment 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 thevalignmentproperty - See Also:
getValignment
public final VPos getValignment()
valignment 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
valignmentproperty - See Also:
valignmentProperty
public final ObjectProperty<VPos> valignmentProperty()
- Returns:
- the
valignmentproperty - See Also:
setFillHeight
public final void setFillHeight(boolean value)
fillHeight 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 thefillHeightproperty - See Also:
isFillHeight
public final boolean isFillHeight()
fillHeight 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
fillHeightproperty - See Also:
fillHeightProperty
public final BooleanProperty fillHeightProperty()
The default value is true.
- Returns:
- the
fillHeightproperty - See Also:
toString
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.