Class ColumnConstraints
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 invalid input: '<' 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
TypePropertyDescriptionThe horizontal fill policy for the column.final ObjectProperty<HPos>
The horizontal alignment for the column.final ObjectProperty<Priority>
The horizontal grow priority for the column.final DoubleProperty
The maximum width for the column.final DoubleProperty
The minimum width for the column.final DoubleProperty
The width percentage of the column.final DoubleProperty
The preferred width for the column. -
Field Summary
Fields inherited from class javafx.scene.layout.ConstraintsBase
CONSTRAIN_TO_PREF
-
Constructor Summary
ConstructorDescriptionCreate a column constraint object with no properties set.ColumnConstraints
(double width) Creates a column constraint object with a fixed width.ColumnConstraints
(double minWidth, double prefWidth, double maxWidth) Creates a column constraint object with a fixed size range.ColumnConstraints
(double minWidth, double prefWidth, double maxWidth, Priority hgrow, HPos halignment, boolean fillWidth) Creates a column constraint object with a fixed size range, horizontal grow priority, horizonal alignment, and horizontal fill behavior. -
Method Summary
Modifier and TypeMethodDescriptionThe horizontal fill policy for the column.final HPos
Gets the value of thehalignment
property.final Priority
getHgrow()
Gets the value of thehgrow
property.final double
Gets the value of themaxWidth
property.final double
Gets the value of theminWidth
property.final double
Gets the value of thepercentWidth
property.final double
Gets the value of theprefWidth
property.final ObjectProperty<HPos>
The horizontal alignment for the column.final ObjectProperty<Priority>
The horizontal grow priority for the column.final boolean
final DoubleProperty
The maximum width for the column.final DoubleProperty
The minimum width for the column.final DoubleProperty
The width percentage of the column.final DoubleProperty
The preferred width for the column.final void
setFillWidth
(boolean value) Sets the value of thefillWidth
property.final void
setHalignment
(HPos value) Sets the value of thehalignment
property.final void
Sets the value of thehgrow
property.final void
setMaxWidth
(double value) Sets the value of themaxWidth
property.final void
setMinWidth
(double value) Sets the value of theminWidth
property.final void
setPercentWidth
(double value) Sets the value of thepercentWidth
property.final void
setPrefWidth
(double value) Sets the value of theprefWidth
property.toString()
Returns a string representation of thisColumnConstraints
object.Methods inherited from class javafx.scene.layout.ConstraintsBase
requestLayout
-
Property Details
-
minWidth
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.
-
prefWidth
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.
-
maxWidth
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.
-
percentWidth
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. -
hgrow
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.
- See Also:
-
halignment
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.
-
fillWidth
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.
- See Also:
-
-
Constructor Details
-
ColumnConstraints
public ColumnConstraints()Create a column constraint object with no properties set. -
ColumnConstraints
public ColumnConstraints(double width) Creates a column constraint object with a fixed width. This is a convenience for setting the preferred width constraint to the fixed value and the minWidth and maxWidth constraints to the USE_PREF_SIZE flag to ensure the column is always that width.- Parameters:
width
- the width of the column
-
ColumnConstraints
public ColumnConstraints(double minWidth, double prefWidth, double maxWidth) Creates a column constraint object with a fixed size range. This is a convenience for setting the minimum, preferred, and maximum width constraints. -
ColumnConstraints
public ColumnConstraints(double minWidth, double prefWidth, double maxWidth, Priority hgrow, HPos halignment, boolean fillWidth) Creates a column constraint object with a fixed size range, horizontal grow priority, horizonal alignment, and horizontal fill behavior.
-
-
Method Details
-
setMinWidth
public final void setMinWidth(double value) Sets the value of theminWidth
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 theminWidth
property- See Also:
-
getMinWidth
public final double getMinWidth()Gets the value of theminWidth
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
minWidth
property - See Also:
-
minWidthProperty
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
minWidth
property - See Also:
-
setPrefWidth
public final void setPrefWidth(double value) Sets the value of theprefWidth
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 theprefWidth
property- See Also:
-
getPrefWidth
public final double getPrefWidth()Gets the value of theprefWidth
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
prefWidth
property - See Also:
-
prefWidthProperty
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
prefWidth
property - See Also:
-
setMaxWidth
public final void setMaxWidth(double value) Sets the value of themaxWidth
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 themaxWidth
property- See Also:
-
getMaxWidth
public final double getMaxWidth()Gets the value of themaxWidth
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
maxWidth
property - See Also:
-
maxWidthProperty
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
maxWidth
property - See Also:
-
setPercentWidth
public final void setPercentWidth(double value) Sets the value of thepercentWidth
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 thepercentWidth
property- See Also:
-
getPercentWidth
public final double getPercentWidth()Gets the value of thepercentWidth
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
percentWidth
property - See Also:
-
percentWidthProperty
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
percentWidth
property - See Also:
-
setHgrow
Sets the value of thehgrow
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 thehgrow
property- See Also:
-
getHgrow
Gets the value of thehgrow
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
hgrow
property - See Also:
-
hgrowProperty
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
hgrow
property - See Also:
-
setHalignment
Sets the value of thehalignment
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 thehalignment
property- See Also:
-
getHalignment
Gets the value of thehalignment
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
halignment
property - See Also:
-
halignmentProperty
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
halignment
property - See Also:
-
setFillWidth
public final void setFillWidth(boolean value) Sets the value of thefillWidth
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 thefillWidth
property- See Also:
-
isFillWidth
public final boolean isFillWidth() -
fillWidthProperty
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
fillWidth
property - See Also:
-
toString
Returns a string representation of thisColumnConstraints
object.
-