public class GridPane extends Pane
A child may be placed anywhere within the grid and may span multiple rows/columns. Children may freely overlap within rows/columns and their stacking order will be defined by the order of the gridpane's children list (0th node in back, last node in front).
GridPane may be styled with backgrounds and borders using CSS. See
Region
superclass for details.
A child's placement within the grid is defined by it's layout constraints:
Constraint | Type | Description |
---|---|---|
columnIndex | integer | column where child's layout area starts. |
rowIndex | integer | row where child's layout area starts. |
columnSpan | integer | the number of columns the child's layout area spans horizontally. |
rowSpan | integer | the number of rows the child's layout area spans vertically. |
If the row/column indices are not explicitly set, then the child will be placed in the first row/column. If row/column spans are not set, they will default to 1. A child's placement constraints can be changed dynamically and the gridpane will update accordingly.
The total number of rows/columns does not need to be specified up front as the gridpane will automatically expand/contract the grid to accommodate the content.
To use the GridPane, an application needs to set the layout constraints on the children and add those children to the gridpane instance. Constraints are set on the children using static setter methods on the GridPane class:
GridPane gridpane = new GridPane();
// Set one constraint at a time...
// Places the button at the first row and second column
Button button = new Button();
GridPane.setRowIndex(button, 0);
GridPane.setColumnIndex(button, 1);
// or convenience methods set more than one constraint at once...
Label label = new Label();
GridPane.setConstraints(label, 2, 0); // column=2 row=0
// don't forget to add children to gridpane
gridpane.getChildren().addAll(button, label);
Applications may also use convenience methods which combine the steps of
setting the constraints and adding the children:
GridPane gridpane = new GridPane();
gridpane.add(new Button(), 1, 0); // column=1 row=0
gridpane.add(new Label(), 2, 0); // column=2 row=0
GridPane gridpane = new GridPane();
gridpane.getColumnConstraints().add(new ColumnConstraints(100)); // column 0 is 100 wide
gridpane.getColumnConstraints().add(new ColumnConstraints(200)); // column 1 is 200 wide
By default the gridpane will resize rows/columns to their preferred sizes (either
computed from content or fixed), even if the gridpane is resized larger than
its preferred size. If an application needs a particular row or column to
grow if there is extra space, it may set its grow priority on the RowConstraints
or ColumnConstraints object. For example:
GridPane gridpane = new GridPane();
ColumnConstraints column1 = new ColumnConstraints(100,100,Double.MAX_VALUE);
column1.setHgrow(Priority.ALWAYS);
ColumnConstraints column2 = new ColumnConstraints(100);
gridpane.getColumnConstraints().addAll(column1, column2); // first column gets any extra width
Note: Nodes spanning multiple rows/columns will be also size to the preferred sizes. The affected rows/columns are resized by the following priority: grow priorities, last row. This is with respect to row/column constraints.
GridPane gridpane = new GridPane();
ColumnConstraints column1 = new ColumnConstraints();
column1.setPercentWidth(50);
ColumnConstraints column2 = new ColumnConstraints();
column2.setPercentWidth(50);
gridpane.getColumnConstraints().addAll(column1, column2); // each get 50% of width
If a percentage value is set on a row/column, then that value takes precedent and the
row/column's min, pref, max, and grow constraints will be ignored.
Note that if the sum of the widthPercent (or heightPercent) values total greater than 100, the values will be treated as weights. e.g. if 3 columns are each given a widthPercent of 50, then each will be allocated 1/3 of the gridpane's available width (50/(50+50+50)).
A gridpane's parent will resize the gridpane within the gridpane's resizable range during layout. By default the gridpane computes this range based on its content and row/column constraints as outlined in the table below.
width | height | |
---|---|---|
minimum | left/right insets plus the sum of each column's min width. | top/bottom insets plus the sum of each row's min height. |
preferred | left/right insets plus the sum of each column's pref width. | top/bottom insets plus the sum of each row's pref height. |
maximum | Double.MAX_VALUE | Double.MAX_VALUE |
A gridpane's unbounded maximum width and height are an indication to the parent that it may be resized beyond its preferred size to fill whatever space is assigned to it.
GridPane provides properties for setting the size range directly. These properties default to the sentinel value USE_COMPUTED_SIZE, however the application may set them to other values as needed:
gridpane.setPrefSize(300, 300);
// never size the gridpane larger than its preferred size:
gridpane.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
Applications may restore the computed values by setting these properties back
to USE_COMPUTED_SIZE.
GridPane does not clip its content by default, so it is possible that children's bounds may extend outside its own bounds if a child's min size prevents it from being fit within it space.
An application may set additional constraints on children to customize how the child is sized and positioned within the layout area established by it's row/column indices/spans:
Constraint | Type | Description |
---|---|---|
halignment | javafx.geometry.HPos | The horizontal alignment of the child within its layout area. |
valignment | javafx.geometry.VPos | The vertical alignment of the child within its layout area. |
hgrow | javafx.scene.layout.Priority | The horizontal grow priority of the child. |
vgrow | javafx.scene.layout.Priority | The vertical grow priority of the child. |
margin | javafx.geometry.Insets | Margin space around the outside of the child. |
By default the alignment of a child within its layout area is defined by the alignment set for the row and column. If an individual alignment constraint is set on a child, that alignment will override the row/column alignment only for that child. Alignment of other children in the same row or column will not be affected.
Grow priorities, on the other hand, can only be applied to entire rows or columns. Therefore, if a grow priority constraint is set on a single child, it will be used to compute the default grow priority of the encompassing row/column. If a grow priority is set directly on a RowConstraint or ColumnConstraint object, it will override the value computed from content.
Type | Property and Description |
---|---|
<any> |
alignment
The alignment of the grid within the gridpane's width and height.
|
BooleanProperty |
gridLinesVisible
For debug purposes only: controls whether lines are displayed to show the gridpane's rows and columns.
|
DoubleProperty |
hgap
The width of the horizontal gaps between columns.
|
DoubleProperty |
vgap
The height of the vertical gaps between rows.
|
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthProperty
Modifier and Type | Class and Description |
---|---|
private static class |
GridPane.CompositeSize |
private static class |
GridPane.Interval |
private static class |
GridPane.StyleableProperties
*
Stylesheet Handling *
*
|
Modifier and Type | Field and Description |
---|---|
private <any> |
alignment |
private Orientation |
bias |
private static java.lang.String |
COLUMN_INDEX_CONSTRAINT |
private static java.lang.String |
COLUMN_SPAN_CONSTRAINT |
private <any> |
columnConstraints
ColumnConstraints instances can be added to explicitly control individual column
sizing and layout behavior.
|
private Priority[] |
columnGrow |
private GridPane.CompositeSize |
columnMaxWidth |
private GridPane.CompositeSize |
columnMinWidth |
private double |
columnPercentTotal |
private double[] |
columnPercentWidth |
private GridPane.CompositeSize |
columnPrefWidth |
private GridPane.CompositeSize |
currentHeights |
private GridPane.CompositeSize |
currentWidths |
private static java.lang.String |
FILL_HEIGHT_CONSTRAINT |
private static java.lang.String |
FILL_WIDTH_CONSTRAINT |
private static Color |
GRID_LINE_COLOR |
private static double |
GRID_LINE_DASH |
private Group |
gridLines |
private BooleanProperty |
gridLinesVisible |
private static java.lang.String |
HALIGNMENT_CONSTRAINT |
private DoubleProperty |
hgap |
private static java.lang.String |
HGROW_CONSTRAINT |
private static java.lang.String |
MARGIN_CONSTRAINT
BEGIN static methods
|
private static <any> |
marginAccessor |
private boolean |
metricsDirty |
private int |
numColumns |
private int |
numRows |
private boolean |
performingLayout |
static int |
REMAINING
Sentinel value which may be set on a child's row/column span constraint to
indicate that it should span the remaining rows/columns.
|
private static java.lang.String |
ROW_INDEX_CONSTRAINT |
private static java.lang.String |
ROW_SPAN_CONSTRAINT |
private java.util.List<Node>[] |
rowBaseline |
private <any> |
rowConstraints
RowConstraints instances can be added to explicitly control individual row
sizing and layout behavior.
|
private Priority[] |
rowGrow |
private double[] |
rowMaxBaselineComplement |
private GridPane.CompositeSize |
rowMaxHeight |
private double[] |
rowMinBaselineComplement |
private GridPane.CompositeSize |
rowMinHeight |
private double[] |
rowPercentHeight |
private double |
rowPercentTotal |
private double[] |
rowPrefBaselineComplement |
private GridPane.CompositeSize |
rowPrefHeight |
private static java.lang.String |
VALIGNMENT_CONSTRAINT |
private DoubleProperty |
vgap |
private static java.lang.String |
VGROW_CONSTRAINT |
TEMP_VEC2D, USE_COMPUTED_SIZE, USE_PREF_SIZE
Constructor and Description |
---|
GridPane()
Creates a GridPane layout with hgap/vgap = 0 and TOP_LEFT alignment.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Node child,
int columnIndex,
int rowIndex)
Adds a child to the gridpane at the specified column,row position.
|
void |
add(Node child,
int columnIndex,
int rowIndex,
int colspan,
int rowspan)
Adds a child to the gridpane at the specified column,row position and spans.
|
void |
addColumn(int columnIndex,
Node... children)
Convenience method for placing the specified nodes sequentially in a given
column of the gridpane.
|
void |
addRow(int rowIndex,
Node... children)
Convenience method for placing the specified nodes sequentially in a given
row of the gridpane.
|
private double |
adjustColumnWidths(GridPane.CompositeSize widths,
double width) |
private double |
adjustRowHeights(GridPane.CompositeSize heights,
double height) |
<any> |
alignmentProperty()
The alignment of the grid within the gridpane's width and height.
|
static void |
clearConstraints(Node child)
Removes all gridpane constraints from the child node.
|
private void |
computeGridMetrics() |
private GridPane.CompositeSize |
computeHeightsToFit(double height) |
private GridPane.CompositeSize |
computeMaxHeights() |
private GridPane.CompositeSize |
computeMaxWidths() |
protected double |
computeMinHeight(double width)
Computes the minimum height of this region.
|
private GridPane.CompositeSize |
computeMinHeights(double[] widths) |
protected double |
computeMinWidth(double height)
Computes the minimum width of this region.
|
private GridPane.CompositeSize |
computeMinWidths(double[] heights) |
protected double |
computePrefHeight(double width)
Computes the preferred height of this region for the given width;
Region subclasses should override this method to return an appropriate
value based on their content and layout strategy.
|
private GridPane.CompositeSize |
computePrefHeights(double[] widths) |
protected double |
computePrefWidth(double height)
Computes the preferred width of this region for the given height.
|
private GridPane.CompositeSize |
computePrefWidths(double[] heights) |
private GridPane.CompositeSize |
computeWidthsToFit(double width) |
(package private) static void |
createColumn(int columnIndex,
int rowIndex,
Node... nodes) |
private GridPane.CompositeSize |
createCompositeColumns(double initSize) |
private GridPane.CompositeSize |
createCompositeRows(double initSize) |
private Line |
createGridLine(double startX,
double startY,
double endX,
double endY) |
private static Priority[] |
createPriorityArray(int length,
Priority value) |
(package private) static void |
createRow(int rowIndex,
int columnIndex,
Node... nodes) |
Pos |
getAlignment()
Gets the value of the property alignment.
|
private Pos |
getAlignmentInternal() |
private double |
getBaselineComplementForChild(Node child) |
Bounds |
getCellBounds(int columnIndex,
int rowIndex)
Returns the bounds of the cell at the specified column and row position.
|
static java.util.List<<any>> |
getClassCssMetaData() |
<any> |
getColumnConstraints()
Returns list of column constraints.
|
int |
getColumnCount()
Returns the number of columns in this GridPane.
|
private HPos |
getColumnHalignment(int columnIndex) |
static java.lang.Integer |
getColumnIndex(Node child)
Returns the child's column index constraint if set.
|
private double |
getColumnMaxWidth(int columnIndex) |
private double |
getColumnMinWidth(int columnIndex) |
private double |
getColumnPrefWidth(int columnIndex) |
static java.lang.Integer |
getColumnSpan(Node child)
Returns the child's column-span constraint if set.
|
Orientation |
getContentBias() |
java.util.List<<any>> |
getCssMetaData() |
(package private) double[][] |
getGrid() |
static HPos |
getHalignment(Node child)
Returns the child's halignment constraint if set.
|
double |
getHgap()
Gets the value of the property hgap.
|
static Priority |
getHgrow(Node child)
Returns the child's hgrow constraint if set.
|
static Insets |
getMargin(Node child)
Returns the child's margin constraint if set.
|
(package private) static int |
getNodeColumnEnd(Node node) |
private int |
getNodeColumnEndConvertRemaining(Node child) |
(package private) static int |
getNodeColumnIndex(Node node) |
private static int |
getNodeColumnSpan(Node node) |
private static Priority |
getNodeHgrow(Node node) |
(package private) static int |
getNodeRowEnd(Node node) |
private int |
getNodeRowEndConvertRemaining(Node child) |
(package private) static int |
getNodeRowIndex(Node node) |
private static int |
getNodeRowSpan(Node node) |
private static Priority |
getNodeVgrow(Node node) |
private int |
getNumberOfColumns() |
private int |
getNumberOfRows() |
<any> |
getRowConstraints()
Returns list of row constraints.
|
int |
getRowCount()
Returns the number of rows in this GridPane.
|
static java.lang.Integer |
getRowIndex(Node child)
Returns the child's row index constraint if set.
|
private double |
getRowMaxHeight(int rowIndex) |
private double |
getRowMinHeight(int rowIndex) |
private double |
getRowPrefHeight(int rowIndex) |
static java.lang.Integer |
getRowSpan(Node child)
Returns the child's row-span constraint if set.
|
private VPos |
getRowValignment(int rowIndex) |
private double |
getTotalHeightOfNodeRows(Node child,
double[] heights) |
private double |
getTotalWidthOfNodeColumns(Node child,
double[] widths) |
static VPos |
getValignment(Node child)
Returns the child's valignment constraint if set.
|
double |
getVgap()
Gets the value of the property vgap.
|
static Priority |
getVgrow(Node child)
Returns the child's vgrow constraint if set.
|
BooleanProperty |
gridLinesVisibleProperty()
For debug purposes only: controls whether lines are displayed to show the gridpane's rows and columns.
|
private double |
growOrShrinkColumnWidths(GridPane.CompositeSize widths,
Priority priority,
double extraWidth) |
private double |
growOrShrinkRowHeights(GridPane.CompositeSize heights,
Priority priority,
double extraHeight) |
private double |
growToMultiSpanPreferredHeights(GridPane.CompositeSize heights,
double extraHeight) |
private double |
growToMultiSpanPreferredWidths(GridPane.CompositeSize widths,
double extraWidth) |
DoubleProperty |
hgapProperty()
The width of the horizontal gaps between columns.
|
static java.lang.Boolean |
isFillHeight(Node child)
Returns the child's vertical fill policy if set
|
static java.lang.Boolean |
isFillWidth(Node child)
Returns the child's horizontal fill policy if set
|
boolean |
isGridLinesVisible()
Gets the value of the property gridLinesVisible.
|
private boolean |
isNodePositionedByBaseline(Node n) |
protected void |
layoutChildren() |
private void |
layoutGridLines(GridPane.CompositeSize columnWidths,
GridPane.CompositeSize rowHeights,
double x,
double y,
double columnHeight,
double rowWidth) |
void |
requestLayout() |
void |
setAlignment(Pos value)
Sets the value of the property alignment.
|
static void |
setColumnIndex(Node child,
java.lang.Integer value)
Sets the column index for the child when contained by a gridpane
so that it will be positioned starting in that column of the gridpane.
|
static void |
setColumnSpan(Node child,
java.lang.Integer value)
Sets the column span for the child when contained by a gridpane
so that it will span that number of columns horizontally.
|
static void |
setConstraints(Node child,
int columnIndex,
int rowIndex)
Sets the column,row indeces for the child when contained in a gridpane.
|
static void |
setConstraints(Node child,
int columnIndex,
int rowIndex,
int columnspan,
int rowspan)
Sets the column, row, column-span, and row-span value for the child when
contained in a gridpane.
|
static void |
setConstraints(Node child,
int columnIndex,
int rowIndex,
int columnspan,
int rowspan,
HPos halignment,
VPos valignment)
Sets the grid position, spans, and alignment for the child when contained in a gridpane.
|
static void |
setConstraints(Node child,
int columnIndex,
int rowIndex,
int columnspan,
int rowspan,
HPos halignment,
VPos valignment,
Priority hgrow,
Priority vgrow)
Sets the grid position, spans, and alignment for the child when contained in a gridpane.
|
static void |
setConstraints(Node child,
int columnIndex,
int rowIndex,
int columnspan,
int rowspan,
HPos halignment,
VPos valignment,
Priority hgrow,
Priority vgrow,
Insets margin)
Sets the grid position, spans, alignment, grow priorities, and margin for
the child when contained in a gridpane.
|
static void |
setFillHeight(Node child,
java.lang.Boolean value)
Sets the vertical fill policy for the child when contained by a gridpane.
|
static void |
setFillWidth(Node child,
java.lang.Boolean value)
Sets the horizontal fill policy for the child when contained by a gridpane.
|
void |
setGridLinesVisible(boolean value)
Sets the value of the property gridLinesVisible.
|
static void |
setHalignment(Node child,
HPos value)
Sets the horizontal alignment for the child when contained by a gridpane.
|
void |
setHgap(double value)
Sets the value of the property hgap.
|
static void |
setHgrow(Node child,
Priority value)
Sets the horizontal grow priority for the child when contained by a gridpane.
|
static void |
setMargin(Node child,
Insets value)
Sets the margin for the child when contained by a gridpane.
|
static void |
setRowIndex(Node child,
java.lang.Integer value)
Sets the row index for the child when contained by a gridpane
so that it will be positioned starting in that row of the gridpane.
|
static void |
setRowSpan(Node child,
java.lang.Integer value)
Sets the row span for the child when contained by a gridpane
so that it will span that number of rows vertically.
|
static void |
setValignment(Node child,
VPos value)
Sets the vertical alignment for the child when contained by a gridpane.
|
void |
setVgap(double value)
Sets the value of the property vgap.
|
static void |
setVgrow(Node child,
Priority value)
Sets the vertical grow priority for the child when contained by a gridpane.
|
private boolean |
shouldColumnFillWidth(int columnIndex) |
private boolean |
shouldRowFillHeight(int rowIndex) |
java.lang.String |
toString()
Returns a string representation of this
GridPane object. |
DoubleProperty |
vgapProperty()
The height of the vertical gaps between rows.
|
getChildren, getConstraint, setConstraint
addImageListener, adjustHeightByMargin, adjustWidthByMargin, backgroundProperty, borderProperty, boundedNodeSizeWithBias, boundedSize, cacheShapeProperty, centerShapeProperty, computeChildMaxAreaHeight, computeChildMaxAreaWidth, computeChildMinAreaHeight, computeChildMinAreaHeight, computeChildMinAreaWidth, computeChildMinAreaWidth, computeChildPrefAreaHeight, computeChildPrefAreaHeight, computeChildPrefAreaWidth, computeChildPrefAreaWidth, computeMaxHeight, computeMaxMinAreaHeight, computeMaxMinAreaHeight, computeMaxMinAreaHeight, computeMaxMinAreaWidth, computeMaxMinAreaWidth, computeMaxMinAreaWidth, computeMaxPrefAreaHeight, computeMaxPrefAreaHeight, computeMaxPrefAreaHeight, computeMaxPrefAreaWidth, computeMaxPrefAreaWidth, computeMaxPrefAreaWidth, computeMaxWidth, computeXOffset, computeYOffset, createDoubleArray, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getAreaBaselineOffset, getBackground, getBorder, getHeight, getInsets, getMaxBaselineComplement, getMaxHeight, getMaxWidth, getMinBaselineComplement, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefBaselineComplement, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, removeImageListener, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPortionX, snapPortionY, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
public final DoubleProperty hgapProperty
getHgap()
,
setHgap(double)
public final DoubleProperty vgapProperty
getVgap()
,
setVgap(double)
public final <any> alignmentProperty
getAlignment()
,
setAlignment(Pos)
public final BooleanProperty gridLinesVisibleProperty
false
.isGridLinesVisible()
,
setGridLinesVisible(boolean)
public static final int REMAINING
private static final java.lang.String MARGIN_CONSTRAINT
private static final java.lang.String HALIGNMENT_CONSTRAINT
private static final java.lang.String VALIGNMENT_CONSTRAINT
private static final java.lang.String HGROW_CONSTRAINT
private static final java.lang.String VGROW_CONSTRAINT
private static final java.lang.String ROW_INDEX_CONSTRAINT
private static final java.lang.String COLUMN_INDEX_CONSTRAINT
private static final java.lang.String ROW_SPAN_CONSTRAINT
private static final java.lang.String COLUMN_SPAN_CONSTRAINT
private static final java.lang.String FILL_WIDTH_CONSTRAINT
private static final java.lang.String FILL_HEIGHT_CONSTRAINT
private static final <any> marginAccessor
private static final Color GRID_LINE_COLOR
private static final double GRID_LINE_DASH
private DoubleProperty hgap
private DoubleProperty vgap
private <any> alignment
private BooleanProperty gridLinesVisible
private final <any> rowConstraints
private final <any> columnConstraints
private Group gridLines
private Orientation bias
private double[] rowPercentHeight
private double rowPercentTotal
private GridPane.CompositeSize rowMinHeight
private GridPane.CompositeSize rowPrefHeight
private GridPane.CompositeSize rowMaxHeight
private java.util.List<Node>[] rowBaseline
private double[] rowMinBaselineComplement
private double[] rowPrefBaselineComplement
private double[] rowMaxBaselineComplement
private Priority[] rowGrow
private double[] columnPercentWidth
private double columnPercentTotal
private GridPane.CompositeSize columnMinWidth
private GridPane.CompositeSize columnPrefWidth
private GridPane.CompositeSize columnMaxWidth
private Priority[] columnGrow
private boolean metricsDirty
private boolean performingLayout
private int numRows
private int numColumns
private GridPane.CompositeSize currentHeights
private GridPane.CompositeSize currentWidths
public GridPane()
public static void setRowIndex(Node child, java.lang.Integer value)
child
- the child node of a gridpanevalue
- the row index of the childpublic static java.lang.Integer getRowIndex(Node child)
child
- the child node of a gridpanepublic static void setColumnIndex(Node child, java.lang.Integer value)
child
- the child node of a gridpanevalue
- the column index of the childpublic static java.lang.Integer getColumnIndex(Node child)
child
- the child node of a gridpanepublic static void setRowSpan(Node child, java.lang.Integer value)
If a gridpane child has no row span set, it will default to spanning one row. Setting the value to null will remove the constraint.
child
- the child node of a gridpanevalue
- the row span of the childpublic static java.lang.Integer getRowSpan(Node child)
child
- the child node of a gridpanepublic static void setColumnSpan(Node child, java.lang.Integer value)
If a gridpane child has no column span set, it will default to spanning one column. Setting the value to null will remove the constraint.
child
- the child node of a gridpanevalue
- the column span of the childpublic static java.lang.Integer getColumnSpan(Node child)
child
- the child node of a gridpanepublic static void setMargin(Node child, Insets value)
child
- the child node of a gridpanevalue
- the margin of space around the childpublic static Insets getMargin(Node child)
child
- the child node of a gridpaneprivate double getBaselineComplementForChild(Node child)
public static void setHalignment(Node child, HPos value)
child
- the child node of a gridpanevalue
- the hozizontal alignment for the childpublic static HPos getHalignment(Node child)
child
- the child node of a gridpanepublic static void setValignment(Node child, VPos value)
child
- the child node of a gridpanevalue
- the vertical alignment for the childpublic static VPos getValignment(Node child)
child
- the child node of a gridpanepublic static void setHgrow(Node child, Priority value)
child
- the child of a gridpanevalue
- the horizontal grow priority for the childpublic static Priority getHgrow(Node child)
child
- the child node of a gridpanepublic static void setVgrow(Node child, Priority value)
child
- the child of a gridpanevalue
- the vertical grow priority for the childpublic static Priority getVgrow(Node child)
child
- the child node of a gridpanepublic static void setFillWidth(Node child, java.lang.Boolean value)
child
- the child node of a gridpanevalue
- the horizontal fill policy or null for unsetpublic static java.lang.Boolean isFillWidth(Node child)
child
- the child node of a gridpanepublic static void setFillHeight(Node child, java.lang.Boolean value)
child
- the child node of a gridpanevalue
- the vertical fill policy or null for unsetpublic static java.lang.Boolean isFillHeight(Node child)
child
- the child node of a gridpanepublic static void setConstraints(Node child, int columnIndex, int rowIndex)
child
- the child node of a gridpanecolumnIndex
- the column index position for the childrowIndex
- the row index position for the childpublic static void setConstraints(Node child, int columnIndex, int rowIndex, int columnspan, int rowspan)
child
- the child node of a gridpanecolumnIndex
- the column index position for the childrowIndex
- the row index position for the childcolumnspan
- the number of columns the child should spanrowspan
- the number of rows the child should spanpublic static void setConstraints(Node child, int columnIndex, int rowIndex, int columnspan, int rowspan, HPos halignment, VPos valignment)
child
- the child node of a gridpanecolumnIndex
- the column index position for the childrowIndex
- the row index position for the childcolumnspan
- the number of columns the child should spanrowspan
- the number of rows the child should spanhalignment
- the horizontal alignment of the childvalignment
- the vertical alignment of the childpublic static void setConstraints(Node child, int columnIndex, int rowIndex, int columnspan, int rowspan, HPos halignment, VPos valignment, Priority hgrow, Priority vgrow)
child
- the child node of a gridpanecolumnIndex
- the column index position for the childrowIndex
- the row index position for the childcolumnspan
- the number of columns the child should spanrowspan
- the number of rows the child should spanhalignment
- the horizontal alignment of the childvalignment
- the vertical alignment of the childhgrow
- the horizontal grow priority of the childvgrow
- the vertical grow priority of the childpublic static void setConstraints(Node child, int columnIndex, int rowIndex, int columnspan, int rowspan, HPos halignment, VPos valignment, Priority hgrow, Priority vgrow, Insets margin)
child
- the child node of a gridpanecolumnIndex
- the column index position for the childrowIndex
- the row index position for the childcolumnspan
- the number of columns the child should spanrowspan
- the number of rows the child should spanhalignment
- the horizontal alignment of the childvalignment
- the vertical alignment of the childhgrow
- the horizontal grow priority of the childvgrow
- the vertical grow priority of the childmargin
- the margin of space around the childpublic static void clearConstraints(Node child)
child
- the child nodestatic void createRow(int rowIndex, int columnIndex, Node... nodes)
static void createColumn(int columnIndex, int rowIndex, Node... nodes)
static int getNodeRowIndex(Node node)
private static int getNodeRowSpan(Node node)
static int getNodeRowEnd(Node node)
static int getNodeColumnIndex(Node node)
private static int getNodeColumnSpan(Node node)
static int getNodeColumnEnd(Node node)
private static Priority getNodeHgrow(Node node)
private static Priority getNodeVgrow(Node node)
public final DoubleProperty hgapProperty()
getHgap()
,
setHgap(double)
public final void setHgap(double value)
public final double getHgap()
public final DoubleProperty vgapProperty()
getVgap()
,
setVgap(double)
public final void setVgap(double value)
public final double getVgap()
public final <any> alignmentProperty()
getAlignment()
,
setAlignment(Pos)
public final void setAlignment(Pos value)
public final Pos getAlignment()
private Pos getAlignmentInternal()
public final BooleanProperty gridLinesVisibleProperty()
false
.isGridLinesVisible()
,
setGridLinesVisible(boolean)
public final void setGridLinesVisible(boolean value)
public final boolean isGridLinesVisible()
public final <any> getRowConstraints()
public final <any> getColumnConstraints()
public void add(Node child, int columnIndex, int rowIndex)
child
- the node being added to the gridpanecolumnIndex
- the column index position for the child within the gridpane, counting from 0rowIndex
- the row index position for the child within the gridpane, counting from 0public void add(Node child, int columnIndex, int rowIndex, int colspan, int rowspan)
child
- the node being added to the gridpanecolumnIndex
- the column index position for the child within the gridpane, counting from 0rowIndex
- the row index position for the child within the gridpane, counting from 0colspan
- the number of columns the child's layout area should spanrowspan
- the number of rows the child's layout area should spanpublic void addRow(int rowIndex, Node... children)
rowIndex
- the row index position for the children within the gridpanechildren
- the nodes to be added as a row in the gridpanepublic void addColumn(int columnIndex, Node... children)
columnIndex
- the column index position for the children within the gridpanechildren
- the nodes to be added as a column in the gridpaneprivate int getNumberOfRows()
private int getNumberOfColumns()
private boolean isNodePositionedByBaseline(Node n)
private void computeGridMetrics()
protected double computeMinWidth(double height)
Region
computeMinWidth
in class Region
protected double computeMinHeight(double width)
Region
computeMinHeight
in class Region
protected double computePrefWidth(double height)
Region
computePrefWidth
in class Region
protected double computePrefHeight(double width)
Region
computePrefHeight
in class Region
private VPos getRowValignment(int rowIndex)
private HPos getColumnHalignment(int columnIndex)
private double getColumnMinWidth(int columnIndex)
private double getRowMinHeight(int rowIndex)
private double getColumnMaxWidth(int columnIndex)
private double getColumnPrefWidth(int columnIndex)
private double getRowPrefHeight(int rowIndex)
private double getRowMaxHeight(int rowIndex)
private boolean shouldRowFillHeight(int rowIndex)
private boolean shouldColumnFillWidth(int columnIndex)
private double getTotalWidthOfNodeColumns(Node child, double[] widths)
private GridPane.CompositeSize computeMaxHeights()
private GridPane.CompositeSize computePrefHeights(double[] widths)
private GridPane.CompositeSize computeMinHeights(double[] widths)
private double getTotalHeightOfNodeRows(Node child, double[] heights)
private GridPane.CompositeSize computeMaxWidths()
private GridPane.CompositeSize computePrefWidths(double[] heights)
private GridPane.CompositeSize computeMinWidths(double[] heights)
private GridPane.CompositeSize computeHeightsToFit(double height)
private GridPane.CompositeSize computeWidthsToFit(double width)
public Orientation getContentBias()
public void requestLayout()
protected void layoutChildren()
private double adjustRowHeights(GridPane.CompositeSize heights, double height)
private double growToMultiSpanPreferredHeights(GridPane.CompositeSize heights, double extraHeight)
private double growOrShrinkRowHeights(GridPane.CompositeSize heights, Priority priority, double extraHeight)
private double adjustColumnWidths(GridPane.CompositeSize widths, double width)
private double growToMultiSpanPreferredWidths(GridPane.CompositeSize widths, double extraWidth)
private double growOrShrinkColumnWidths(GridPane.CompositeSize widths, Priority priority, double extraWidth)
private void layoutGridLines(GridPane.CompositeSize columnWidths, GridPane.CompositeSize rowHeights, double x, double y, double columnHeight, double rowWidth)
private Line createGridLine(double startX, double startY, double endX, double endY)
public java.lang.String toString()
GridPane
object.GridPane
object.private GridPane.CompositeSize createCompositeRows(double initSize)
private GridPane.CompositeSize createCompositeColumns(double initSize)
private int getNodeRowEndConvertRemaining(Node child)
private int getNodeColumnEndConvertRemaining(Node child)
double[][] getGrid()
public static java.util.List<<any>> getClassCssMetaData()
public java.util.List<<any>> getCssMetaData()
getCssMetaData
in class Region
public final int getRowCount()
public final int getColumnCount()
public final Bounds getCellBounds(int columnIndex, int rowIndex)
columnIndex
- the column index position for the cell within this
GridPane, counting from 0rowIndex
- the row index position for the cell within this GridPane,
counting from 0