Class ColumnConstraints
public class ColumnConstraints extends ConstraintsBase
GridPane. If a ColumnConstraints object is added for a column in a gridpane, the gridpane will use those constraint values when computing the column's width and layout. For example, to create a GridPane with 5 columns 100 pixels wide:
GridPane gridpane = new GridPane();
for (int i = 0; i < 5; i++) {
ColumnConstraints column = new ColumnConstraints(100);
gridpane.getColumnConstraints().add(column);
}
Or, to create a GridPane where columns take 25%, 50%, 25% of its width:
GridPane gridpane = new GridPane();
ColumnConstraints col1 = new ColumnConstraints();
col1.setPercentWidth(25);
ColumnConstraints col2 = new ColumnConstraints();
col2.setPercentWidth(50);
ColumnConstraints col3 = new ColumnConstraints();
col3.setPercentWidth(25);
gridpane.getColumnConstraints().addAll(col1,col2,col3);
Note that adding an empty ColumnConstraints object has the effect of not setting any constraints, leaving the GridPane to compute the column's layout based solely on its content's size preferences and constraints.- Since:
- JavaFX 2.0
Property Summary
| Type | Property | Description |
|---|---|---|
final BooleanProperty |
fillWidth |
The horizontal fill policy for the column. |
final ObjectProperty<HPos> |
halignment |
The horizontal alignment for the column. |
final ObjectProperty<Priority> |
hgrow |
The horizontal grow priority for the column. |
final DoubleProperty |
maxWidth |
The maximum width for the column. |
final DoubleProperty |
minWidth |
The minimum width for the column. |
final DoubleProperty |
percentWidth |
The width percentage of the column. |
final DoubleProperty |
prefWidth |
The preferred width for the column. |
Field Summary
Fields declared in class javafx.scene.layout.ConstraintsBase
CONSTRAIN_TO_PREF
Constructor Summary
| Constructor | Description |
|---|---|
ColumnConstraints() |
Create a column constraint object with no properties set. |
ColumnConstraints |
Creates a column constraint object with a fixed width. |
ColumnConstraints |
Creates a column constraint object with a fixed size range. |
ColumnConstraints |
Creates a column constraint object with a fixed size range, horizontal grow priority, horizonal alignment, and horizontal fill behavior. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
final BooleanProperty |
fillWidthProperty() |
The horizontal fill policy for the column. |
final HPos |
getHalignment() |
Gets the value of the halignment property. |
final Priority |
getHgrow() |
Gets the value of the hgrow property. |
final double |
getMaxWidth() |
Gets the value of the maxWidth property. |
final double |
getMinWidth() |
Gets the value of the minWidth property. |
final double |
getPercentWidth() |
Gets the value of the percentWidth property. |
final double |
getPrefWidth() |
Gets the value of the prefWidth property. |
final ObjectProperty<HPos> |
halignmentProperty() |
The horizontal alignment for the column. |
final ObjectProperty<Priority> |
hgrowProperty() |
The horizontal grow priority for the column. |
final boolean |
isFillWidth() |
Gets the value of the fillWidth property. |
final DoubleProperty |
maxWidthProperty() |
The maximum width for the column. |
final DoubleProperty |
minWidthProperty() |
The minimum width for the column. |
final DoubleProperty |
percentWidthProperty() |
The width percentage of the column. |
final DoubleProperty |
prefWidthProperty() |
The preferred width for the column. |
final void |
setFillWidth |
Sets the value of the fillWidth property. |
final void |
setHalignment |
Sets the value of the halignment property. |
final void |
setHgrow |
Sets the value of the hgrow property. |
final void |
setMaxWidth |
Sets the value of the maxWidth property. |
final void |
setMinWidth |
Sets the value of the minWidth property. |
final void |
setPercentWidth |
Sets the value of the percentWidth property. |
final void |
setPrefWidth |
Sets the value of the prefWidth property. |
String |
toString() |
Returns a string representation of this ColumnConstraints object. |
Methods declared in class javafx.scene.layout.ConstraintsBase
requestLayout
Property Details
minWidth
public final DoubleProperty minWidthProperty
The default value is USE_COMPUTED_SIZE, which means the minimum width will be computed to be the largest minimum width of the column's content.
prefWidth
public final DoubleProperty prefWidthProperty
The default value is USE_COMPUTED_SIZE, which means the preferred width will be computed to be the largest preferred width of the column's content.
maxWidth
public final DoubleProperty maxWidthProperty
The default value is USE_COMPUTED_SIZE, which means the maximum width will be computed to be the smallest maximum width of the column's content.
percentWidth
public final DoubleProperty percentWidthProperty
hgrow
public final ObjectProperty<Priority> hgrowProperty
This default value is null, which means that the column's grow priority will be derived from largest grow priority set on a content node.
- See Also:
halignment
public final ObjectProperty<HPos> halignmentProperty
The default value is null, which means the column alignment will fall back to the default halignment set on the gridpane.
fillWidth
public final BooleanProperty fillWidthProperty
The default value is true.
Constructor Details
ColumnConstraints
public ColumnConstraints()
ColumnConstraints
public ColumnConstraints(double width)
- Parameters:
-
width- the width of the column
ColumnConstraints
public ColumnConstraints(double minWidth, double prefWidth, double maxWidth)
- Parameters:
-
minWidth- the minimum width -
prefWidth- the preferred width -
maxWidth- the maximum width
ColumnConstraints
public ColumnConstraints(double minWidth, double prefWidth, double maxWidth, Priority hgrow, HPos halignment, boolean fillWidth)
- Parameters:
-
minWidth- the minimum width -
prefWidth- the preferred width -
maxWidth- the maximum width -
hgrow- the horizontal grow priority -
halignment- the horizonal alignment -
fillWidth- the horizontal fill behavior
Method Details
setMinWidth
public final void setMinWidth(double value)
minWidth property.- Property description:
- The minimum width for the column. This property is ignored if percentWidth is set.
The default value is USE_COMPUTED_SIZE, which means the minimum width will be computed to be the largest minimum width of the column's content.
- Parameters:
-
value- the value for theminWidthproperty - See Also:
getMinWidth
public final double getMinWidth()
minWidth property.- Property description:
- The minimum width for the column. This property is ignored if percentWidth is set.
The default value is USE_COMPUTED_SIZE, which means the minimum width will be computed to be the largest minimum width of the column's content.
- Returns:
- the value of the
minWidthproperty - See Also:
minWidthProperty
public final DoubleProperty minWidthProperty()
The default value is USE_COMPUTED_SIZE, which means the minimum width will be computed to be the largest minimum width of the column's content.
- Returns:
- the
minWidthproperty - See Also:
setPrefWidth
public final void setPrefWidth(double value)
prefWidth property.- Property description:
- The preferred width for the column. This property is ignored if percentWidth is set.
The default value is USE_COMPUTED_SIZE, which means the preferred width will be computed to be the largest preferred width of the column's content.
- Parameters:
-
value- the value for theprefWidthproperty - See Also:
getPrefWidth
public final double getPrefWidth()
prefWidth property.- Property description:
- The preferred width for the column. This property is ignored if percentWidth is set.
The default value is USE_COMPUTED_SIZE, which means the preferred width will be computed to be the largest preferred width of the column's content.
- Returns:
- the value of the
prefWidthproperty - See Also:
prefWidthProperty
public final DoubleProperty prefWidthProperty()
The default value is USE_COMPUTED_SIZE, which means the preferred width will be computed to be the largest preferred width of the column's content.
- Returns:
- the
prefWidthproperty - See Also:
setMaxWidth
public final void setMaxWidth(double value)
maxWidth property.- Property description:
- The maximum width for the column. This property is ignored if percentWidth is set.
The default value is USE_COMPUTED_SIZE, which means the maximum width will be computed to be the smallest maximum width of the column's content.
- Parameters:
-
value- the value for themaxWidthproperty - See Also:
getMaxWidth
public final double getMaxWidth()
maxWidth property.- Property description:
- The maximum width for the column. This property is ignored if percentWidth is set.
The default value is USE_COMPUTED_SIZE, which means the maximum width will be computed to be the smallest maximum width of the column's content.
- Returns:
- the value of the
maxWidthproperty - See Also:
maxWidthProperty
public final DoubleProperty maxWidthProperty()
The default value is USE_COMPUTED_SIZE, which means the maximum width will be computed to be the smallest maximum width of the column's content.
- Returns:
- the
maxWidthproperty - See Also:
setPercentWidth
public final void setPercentWidth(double value)
percentWidth property.- Property description:
- The width percentage of the column. If set to a value greater than 0, the column will be resized to this percentage of the gridpane's available width and the other size constraints (minWidth, prefWidth, maxWidth, hgrow) will be ignored. The default value is -1, which means the percentage will be ignored.
- Parameters:
-
value- the value for thepercentWidthproperty - See Also:
getPercentWidth
public final double getPercentWidth()
percentWidth property.- Property description:
- The width percentage of the column. If set to a value greater than 0, the column will be resized to this percentage of the gridpane's available width and the other size constraints (minWidth, prefWidth, maxWidth, hgrow) will be ignored. The default value is -1, which means the percentage will be ignored.
- Returns:
- the value of the
percentWidthproperty - See Also:
percentWidthProperty
public final DoubleProperty percentWidthProperty()
- Returns:
- the
percentWidthproperty - See Also:
setHgrow
public final void setHgrow(Priority value)
hgrow property.- Property description:
- The horizontal grow priority for the column. If set, the gridpane will use this priority to determine whether the column should be given any additional width if the gridpane is resized larger than its preferred width. This property is ignored if percentWidth is set.
This default value is null, which means that the column's grow priority will be derived from largest grow priority set on a content node.
- Parameters:
-
value- the value for thehgrowproperty - See Also:
getHgrow
public final Priority getHgrow()
hgrow property.- Property description:
- The horizontal grow priority for the column. If set, the gridpane will use this priority to determine whether the column should be given any additional width if the gridpane is resized larger than its preferred width. This property is ignored if percentWidth is set.
This default value is null, which means that the column's grow priority will be derived from largest grow priority set on a content node.
- Returns:
- the value of the
hgrowproperty - See Also:
hgrowProperty
public final ObjectProperty<Priority> hgrowProperty()
This default value is null, which means that the column's grow priority will be derived from largest grow priority set on a content node.
- Returns:
- the
hgrowproperty - See Also:
setHalignment
public final void setHalignment(HPos value)
halignment property.- Property description:
- The horizontal alignment for the column. If set, will be the default horizontal alignment for nodes contained within the column.
The default value is null, which means the column alignment will fall back to the default halignment set on the gridpane.
- Parameters:
-
value- the value for thehalignmentproperty - See Also:
getHalignment
public final HPos getHalignment()
halignment property.- Property description:
- The horizontal alignment for the column. If set, will be the default horizontal alignment for nodes contained within the column.
The default value is null, which means the column alignment will fall back to the default halignment set on the gridpane.
- Returns:
- the value of the
halignmentproperty - See Also:
halignmentProperty
public final ObjectProperty<HPos> halignmentProperty()
The default value is null, which means the column alignment will fall back to the default halignment set on the gridpane.
- Returns:
- the
halignmentproperty - See Also:
setFillWidth
public final void setFillWidth(boolean value)
fillWidth property.- Property description:
- The horizontal fill policy for the column. The gridpane will use this property to determine whether nodes contained within the column should be expanded to fill the column or kept to their preferred widths.
The default value is true.
- Parameters:
-
value- the value for thefillWidthproperty - See Also:
isFillWidth
public final boolean isFillWidth()
fillWidth property.- Property description:
- The horizontal fill policy for the column. The gridpane will use this property to determine whether nodes contained within the column should be expanded to fill the column or kept to their preferred widths.
The default value is true.
- Returns:
- the value of the
fillWidthproperty - See Also:
fillWidthProperty
public final BooleanProperty fillWidthProperty()
The default value is true.
- Returns:
- the
fillWidthproperty - See Also:
toString
public String toString()
ColumnConstraints object.- Overrides:
-
toStringin classObject - Returns:
- a string representation of this
ColumnConstraintsobject.
© 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.