- java.lang.Object
-
- javafx.scene.layout.ConstraintsBase
-
- javafx.scene.layout.ColumnConstraints
-
public class ColumnConstraints extends ConstraintsBase
Defines optional layout constraints for a column in aGridPane
. 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:
Or, to create a GridPane where columns take 25%, 50%, 25% of its width:GridPane gridpane = new GridPane(); for (int i = 0; i < 5; i++) { ColumnConstraints column = new ColumnConstraints(100); gridpane.getColumnConstraints().add(column); }
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.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);
- Since:
- JavaFX 2.0
-
-
Property Summary
Properties Type Property Description BooleanProperty
fillWidth
The horizontal fill policy for the column.ObjectProperty<HPos>
halignment
The horizontal alignment for the column.ObjectProperty<Priority>
hgrow
The horizontal grow priority for the column.DoubleProperty
maxWidth
The maximum width for the column.DoubleProperty
minWidth
The minimum width for the column.DoubleProperty
percentWidth
The width percentage of the column.DoubleProperty
prefWidth
The preferred width for the column.
-
Field Summary
-
Fields declared in class javafx.scene.layout.ConstraintsBase
CONSTRAIN_TO_PREF
-
-
Constructor Summary
Constructors Constructor Description ColumnConstraints()
Create 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleanProperty
fillWidthProperty()
The horizontal fill policy for the column.HPos
getHalignment()
Gets the value of the property halignment.Priority
getHgrow()
Gets the value of the property hgrow.double
getMaxWidth()
Gets the value of the property maxWidth.double
getMinWidth()
Gets the value of the property minWidth.double
getPercentWidth()
Gets the value of the property percentWidth.double
getPrefWidth()
Gets the value of the property prefWidth.ObjectProperty<HPos>
halignmentProperty()
The horizontal alignment for the column.ObjectProperty<Priority>
hgrowProperty()
The horizontal grow priority for the column.boolean
isFillWidth()
Gets the value of the property fillWidth.DoubleProperty
maxWidthProperty()
The maximum width for the column.DoubleProperty
minWidthProperty()
The minimum width for the column.DoubleProperty
percentWidthProperty()
The width percentage of the column.DoubleProperty
prefWidthProperty()
The preferred width for the column.void
setFillWidth(boolean value)
Sets the value of the property fillWidth.void
setHalignment(HPos value)
Sets the value of the property halignment.void
setHgrow(Priority value)
Sets the value of the property hgrow.void
setMaxWidth(double value)
Sets the value of the property maxWidth.void
setMinWidth(double value)
Sets the value of the property minWidth.void
setPercentWidth(double value)
Sets the value of the property percentWidth.void
setPrefWidth(double value)
Sets the value of the property prefWidth.String
toString()
Returns a string representation of thisColumnConstraints
object.-
Methods declared in class javafx.scene.layout.ConstraintsBase
requestLayout
-
-
-
-
Property Detail
-
minWidth
public final DoubleProperty 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.
- See Also:
getMinWidth()
,setMinWidth(double)
-
prefWidth
public final DoubleProperty 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.
- See Also:
getPrefWidth()
,setPrefWidth(double)
-
maxWidth
public final DoubleProperty 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.
- See Also:
getMaxWidth()
,setMaxWidth(double)
-
percentWidth
public final DoubleProperty 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.- See Also:
getPercentWidth()
,setPercentWidth(double)
-
hgrow
public final ObjectProperty<Priority> 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.
- See Also:
getHgrow()
,setHgrow(Priority)
-
halignment
public final ObjectProperty<HPos> 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.
- See Also:
getHalignment()
,setHalignment(HPos)
-
fillWidth
public final BooleanProperty 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.
- See Also:
isFillWidth()
,setFillWidth(boolean)
-
-
Constructor Detail
-
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.- Parameters:
minWidth
- the minimum widthprefWidth
- the preferred widthmaxWidth
- the maximum width
-
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.- Parameters:
minWidth
- the minimum widthprefWidth
- the preferred widthmaxWidth
- the maximum widthhgrow
- the horizontal grow priorityhalignment
- the horizonal alignmentfillWidth
- the horizontal fill behavior
-
-
Method Detail
-
setMinWidth
public final void setMinWidth(double value)
Sets the value of the property minWidth.- 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.
-
getMinWidth
public final double getMinWidth()
Gets the value of the property minWidth.- 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.
-
minWidthProperty
public final DoubleProperty 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.
- See Also:
getMinWidth()
,setMinWidth(double)
-
setPrefWidth
public final void setPrefWidth(double value)
Sets the value of the property prefWidth.- 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.
-
getPrefWidth
public final double getPrefWidth()
Gets the value of the property prefWidth.- 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.
-
prefWidthProperty
public final DoubleProperty 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.
- See Also:
getPrefWidth()
,setPrefWidth(double)
-
setMaxWidth
public final void setMaxWidth(double value)
Sets the value of the property maxWidth.- 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.
-
getMaxWidth
public final double getMaxWidth()
Gets the value of the property maxWidth.- 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.
-
maxWidthProperty
public final DoubleProperty 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.
- See Also:
getMaxWidth()
,setMaxWidth(double)
-
setPercentWidth
public final void setPercentWidth(double value)
Sets the value of the property percentWidth.- 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.
-
getPercentWidth
public final double getPercentWidth()
Gets the value of the property percentWidth.- 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.
-
percentWidthProperty
public final DoubleProperty 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.- See Also:
getPercentWidth()
,setPercentWidth(double)
-
setHgrow
public final void setHgrow(Priority value)
Sets the value of the property hgrow.- 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.
-
getHgrow
public final Priority getHgrow()
Gets the value of the property hgrow.- 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.
-
hgrowProperty
public final ObjectProperty<Priority> 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.
- See Also:
getHgrow()
,setHgrow(Priority)
-
setHalignment
public final void setHalignment(HPos value)
Sets the value of the property halignment.- 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.
-
getHalignment
public final HPos getHalignment()
Gets the value of the property halignment.- 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.
-
halignmentProperty
public final ObjectProperty<HPos> 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.
- See Also:
getHalignment()
,setHalignment(HPos)
-
setFillWidth
public final void setFillWidth(boolean value)
Sets the value of the property fillWidth.- 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.
-
isFillWidth
public final boolean isFillWidth()
Gets the value of the property fillWidth.- 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.
-
fillWidthProperty
public final BooleanProperty 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.
- See Also:
isFillWidth()
,setFillWidth(boolean)
-
-