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.
| Modifier and Type | Field and Description |
|---|---|
| private BooleanProperty | fillWidth
The horizontal fill policy for the column. |
| private ObjectProperty | halignment
The horizontal alignment for the column. |
| private ObjectProperty | hgrow
The horizontal grow priority for the column. |
| private DoubleProperty | maxWidth
The maximum width for the column. |
| private DoubleProperty | minWidth
The minimum width for the column. |
| private DoubleProperty | percentWidth
The width percentage of the column. |
| private DoubleProperty | prefWidth
The preferred width for the column. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ColumnConstraints(double
the width of the column width)Creates a column constraint object with a fixed width. |
| public | ColumnConstraints(double
the minimum width minWidth, double the preferred width prefWidth, double the maximum width maxWidth)Creates a column constraint object with a fixed size range. |
| public | ColumnConstraints(double
the minimum width minWidth, double the preferred width prefWidth, double the maximum width maxWidth, Priority the horizontal grow priority hgrow, HPos the horizontal alignment halignment, boolean the horizontal fill behavior fillWidth)Creates a column constraint object with a fixed size range, horizontal grow priority, horizontal alignment, and horizontal fill behavior. |
| Modifier and Type | Method and Description |
|---|---|
| public final BooleanProperty | |
| public final HPos | |
| public final Priority | |
| public final double | |
| public final double | |
| public final double | |
| public final double | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final boolean | |
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public String | Returns: a string representation of thisColumnConstraints object.Overrides java. Returns a string representation of this |
| fillWidth | back to summary |
|---|---|
| private BooleanProperty 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. | |
| halignment | back to summary |
|---|---|
| private ObjectProperty<HPos> 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. | |
| hgrow | back to summary |
|---|---|
| private ObjectProperty<Priority> 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. | |
| maxWidth | back to summary |
|---|---|
| private DoubleProperty 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. | |
| minWidth | back to summary |
|---|---|
| private DoubleProperty 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. | |
| percentWidth | back to summary |
|---|---|
| private DoubleProperty 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. | |
| prefWidth | back to summary |
|---|---|
| private DoubleProperty 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. | |
| ColumnConstraints | back to summary |
|---|---|
| public ColumnConstraints() Create a column constraint object with no properties set. | |
| ColumnConstraints | back to summary |
|---|---|
| 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.
| |
| ColumnConstraints | back to summary |
|---|---|
| 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 | back to summary |
|---|---|
| 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, horizontal alignment, and horizontal fill behavior. | |
| fillWidthProperty | back to summary |
|---|---|
| public final BooleanProperty fillWidthProperty() | |
| getHalignment | back to summary |
|---|---|
| public final HPos getHalignment() | |
| getHgrow | back to summary |
|---|---|
| public final Priority getHgrow() | |
| getMaxWidth | back to summary |
|---|---|
| public final double getMaxWidth() | |
| getMinWidth | back to summary |
|---|---|
| public final double getMinWidth() | |
| getPercentWidth | back to summary |
|---|---|
| public final double getPercentWidth() | |
| getPrefWidth | back to summary |
|---|---|
| public final double getPrefWidth() | |
| halignmentProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| hgrowProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| isFillWidth | back to summary |
|---|---|
| public final boolean isFillWidth() | |
| maxWidthProperty | back to summary |
|---|---|
| public final DoubleProperty maxWidthProperty() | |
| minWidthProperty | back to summary |
|---|---|
| public final DoubleProperty minWidthProperty() | |
| percentWidthProperty | back to summary |
|---|---|
| public final DoubleProperty percentWidthProperty() | |
| prefWidthProperty | back to summary |
|---|---|
| public final DoubleProperty prefWidthProperty() | |
| setFillWidth | back to summary |
|---|---|
| public final void setFillWidth(boolean value) | |
| setHalignment | back to summary |
|---|---|
| public final void setHalignment(HPos value) | |
| setHgrow | back to summary |
|---|---|
| public final void setHgrow(Priority value) | |
| setMaxWidth | back to summary |
|---|---|
| public final void setMaxWidth(double value) | |
| setMinWidth | back to summary |
|---|---|
| public final void setMinWidth(double value) | |
| setPercentWidth | back to summary |
|---|---|
| public final void setPercentWidth(double value) | |
| setPrefWidth | back to summary |
|---|---|
| public final void setPrefWidth(double value) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this | |