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.CONSTRAIN_TO_PREF
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
BooleanProperty |
fillWidthProperty() |
HPos |
getHalignment() |
Priority |
getHgrow() |
double |
getMaxWidth() |
double |
getMinWidth() |
double |
getPercentWidth() |
double |
getPrefWidth() |
ObjectProperty<HPos> |
halignmentProperty() |
ObjectProperty<Priority> |
hgrowProperty() |
boolean |
isFillWidth() |
DoubleProperty |
maxWidthProperty() |
DoubleProperty |
minWidthProperty() |
DoubleProperty |
percentWidthProperty() |
DoubleProperty |
prefWidthProperty() |
void |
setFillWidth(boolean value) |
void |
setHalignment(HPos value) |
void |
setHgrow(Priority value) |
void |
setMaxWidth(double value) |
void |
setMinWidth(double value) |
void |
setPercentWidth(double value) |
void |
setPrefWidth(double value) |
String |
toString()
Returns a string representation of this
ColumnConstraints object. |
requestLayout
public ColumnConstraints()
public ColumnConstraints(double width)
width
- the width of the columnpublic ColumnConstraints(double minWidth, double prefWidth, double maxWidth)
public final void setMinWidth(double value)
public final double getMinWidth()
public final DoubleProperty minWidthProperty()
public final void setPrefWidth(double value)
public final double getPrefWidth()
public final DoubleProperty prefWidthProperty()
public final void setMaxWidth(double value)
public final double getMaxWidth()
public final DoubleProperty maxWidthProperty()
public final void setPercentWidth(double value)
public final double getPercentWidth()
public final DoubleProperty percentWidthProperty()
public final void setHgrow(Priority value)
public final Priority getHgrow()
public final ObjectProperty<Priority> hgrowProperty()
public final void setHalignment(HPos value)
public final HPos getHalignment()
public final ObjectProperty<HPos> halignmentProperty()
public final void setFillWidth(boolean value)
public final boolean isFillWidth()
public final BooleanProperty fillWidthProperty()
Copyright © 2020. All rights reserved.