APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.layout

public Class ColumnConstraints

extends ConstraintsBase
Class Inheritance
Static Imports
javafx.scene.layout.Region.USE_COMPUTED_SIZE, .Region.USE_PREF_SIZE

Defines optional layout constraints for a column in a 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

Field Summary

Modifier and TypeField and Description
private BooleanProperty
fillWidth

The horizontal fill policy for the column.

private ObjectProperty<HPos>
halignment

The horizontal alignment for the column.

private ObjectProperty<Priority>
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.

Inherited from javafx.scene.layout.ConstraintsBase:
CONSTRAIN_TO_PREF

Constructor Summary

AccessConstructor and Description
public
ColumnConstraints()

Create a column constraint object with no properties set.

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.

Method Summary

Modifier and TypeMethod 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<HPos>
public final ObjectProperty<Priority>
public final boolean
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
public final void
setFillWidth(boolean value)

public final void
public final void
public final void
setMaxWidth(double value)

public final void
setMinWidth(double value)

public final void
setPercentWidth(double value)

public final void
setPrefWidth(double value)

public String

Returns:

a string representation of this ColumnConstraints object.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this ColumnConstraints object.

Inherited from javafx.scene.layout.ConstraintsBase:
addremoverequestLayout

Field Detail

fillWidthback 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.

halignmentback 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.

hgrowback 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.

maxWidthback 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.

minWidthback 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.

percentWidthback 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.

prefWidthback 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.

Constructor Detail

ColumnConstraintsback to summary
public ColumnConstraints()

Create a column constraint object with no properties set.

ColumnConstraintsback 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.

Parameters
width:double

the width of the column

ColumnConstraintsback 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.

Parameters
minWidth:double

the minimum width

prefWidth:double

the preferred width

maxWidth:double

the maximum width

ColumnConstraintsback 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.

Parameters
minWidth:double

the minimum width

prefWidth:double

the preferred width

maxWidth:double

the maximum width

hgrow:Priority

the horizontal grow priority

halignment:HPos

the horizontal alignment

fillWidth:boolean

the horizontal fill behavior

Method Detail

fillWidthPropertyback to summary
public final BooleanProperty fillWidthProperty()
getHalignmentback to summary
public final HPos getHalignment()
getHgrowback to summary
public final Priority getHgrow()
getMaxWidthback to summary
public final double getMaxWidth()
getMinWidthback to summary
public final double getMinWidth()
getPercentWidthback to summary
public final double getPercentWidth()
getPrefWidthback to summary
public final double getPrefWidth()
halignmentPropertyback to summary
public final ObjectProperty<HPos> halignmentProperty()
hgrowPropertyback to summary
public final ObjectProperty<Priority> hgrowProperty()
isFillWidthback to summary
public final boolean isFillWidth()
maxWidthPropertyback to summary
public final DoubleProperty maxWidthProperty()
minWidthPropertyback to summary
public final DoubleProperty minWidthProperty()
percentWidthPropertyback to summary
public final DoubleProperty percentWidthProperty()
prefWidthPropertyback to summary
public final DoubleProperty prefWidthProperty()
setFillWidthback to summary
public final void setFillWidth(boolean value)
setHalignmentback to summary
public final void setHalignment(HPos value)
setHgrowback to summary
public final void setHgrow(Priority value)
setMaxWidthback to summary
public final void setMaxWidth(double value)
setMinWidthback to summary
public final void setMinWidth(double value)
setPercentWidthback to summary
public final void setPercentWidth(double value)
setPrefWidthback to summary
public final void setPrefWidth(double value)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this ColumnConstraints object.

Returns:String

a string representation of this ColumnConstraints object.

Annotations
@Override