A horizontal tilepane (the default) will tile nodes in rows, wrapping at the tilepane's width. A vertical tilepane will tile nodes in columns, wrapping at the tilepane's height.
The size of each "tile" defaults to the size needed to encompass the largest preferred width and height of the tilepane's children and the tilepane will recompute the size of the tiles as needed to accommodate the largest preferred size of its children as it changes. The application may also control the size of the tiles directly by setting prefTileWidth/prefTileHeight properties to a value other than USE_COMPUTED_SIZE (the default).
Applications should initialize either prefColumns (for horizontal)
or prefRows (for vertical) to establish the tilepane's preferred
size (the arbitrary default is 5). Note that prefColumns/prefRows
is used only for calculating the preferred size and may not reflect the actual
number of rows or columns, which may change as the tilepane is resized and
the tiles are wrapped at its actual boundaries.
The alignment property controls how the rows and columns are aligned
within the bounds of the tilepane and defaults to Pos.TOP_LEFT. It is also possible
to control the alignment of nodes within the individual tiles by setting
tileAlignment, which defaults to Pos.CENTER.
A horizontal tilepane example:
TilePane tile = new TilePane();
tile.setHgap(8);
tile.setPrefColumns(4);
for (int i = 0; i < 20; i++) {
tile.getChildren().add(new ImageView(...));
}
A vertical TilePane example:
TilePane tile = new TilePane(Orientation.VERTICAL);
tile.setTileAlignment(Pos.CENTER_LEFT);
tile.setPrefRows(10);
for (int i = 0; i < 50; i++) {
tile.getChildren().add(new ImageView(...));
}
The TilePane will attempt to resize each child to fill its tile.
If the child could not be sized to fill the tile (either because it was not
resizable or its size limits prevented it) then it will be aligned within the
tile using tileAlignment.
A tilepane's parent will resize the tilepane within the tilepane's resizable range during layout. By default the tilepane computes this range based on its content as outlined in the tables below.
| width | height | |
|---|---|---|
| minimum | left/right insets plus the tile width. | top/bottom insets plus height required to display all tiles when wrapped at a specified width with a vgap between each row. |
| preferred | left/right insets plus prefColumns multiplied by the tile width. | top/bottom insets plus height required to display all tiles when wrapped at a specified width with a vgap between each row. |
| maximum | Double.MAX_VALUE | Double.MAX_VALUE |
| width | height | |
|---|---|---|
| minimum | left/right insets plus width required to display all tiles when wrapped at a specified height with an hgap between each column. | top/bottom insets plus the tile height. |
| preferred | left/right insets plus width required to display all tiles when wrapped at the specified height with an hgap between each column. | top/bottom insets plus prefRows multiplied by the tile height. |
| maximum | Double.MAX_VALUE | Double.MAX_VALUE |
A tilepane'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.
TilePane provides properties for setting the size range directly. These properties default to the sentinel value Region.USE_COMPUTED_SIZE, however the application may set them to other values as needed:
tilePane.setMaxWidth(500);
Applications may restore the computed values by setting these properties back
to Region.USE_COMPUTED_SIZE.
TilePane does not clip its content by default, so it is possible that children's' bounds may extend outside the tiles (and possibly the tilepane bounds) if a child's pref size prevents it from being fit within its tile. Also, if the tilepane is resized smaller than its preferred size, it may not be able to fit all the tiles within its bounds and the content will extend outside.
An application may set constraints on individual children to customize TilePane's layout. For each constraint, TilePane provides a static method for setting it on the child.
| Constraint | Type | Description |
|---|---|---|
| alignment | javafx.geometry.Pos | The alignment of the child within its tile. |
| margin | javafx.geometry.Insets | Margin space around the outside of the child. |
Example:
TilePane tilepane = new TilePane();
for (int i = 0; i < 20; i++) {
Label title = new Label(imageTitle[i]):
Imageview imageview = new ImageView(new Image(imageName[i]));
TilePane.setAlignment(label, Pos.BOTTOM_RIGHT);
tilepane.getChildren().addAll(title, imageview);
}
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private abstract class |
| Modifier and Type | Field and Description |
|---|---|
| private double | |
| private double | |
| private int | |
| private int | |
| private ObjectProperty | |
| private static final String | |
| private DoubleProperty | |
| private static final String | |
| private static final Callback | |
| private ObjectProperty | |
| private IntegerProperty | |
| private IntegerProperty | |
| private DoubleProperty | |
| private DoubleProperty | |
| private ObjectProperty | |
| private TilePane. | |
| private TilePane. | |
| private DoubleProperty |
| Access | Constructor and Description |
|---|---|
| public | |
| public | TilePane(Orientation
the direction the tiles should flow & wrap orientation)Creates a TilePane layout with the specified orientation, prefColumn/prefRows = 5 and hgap/vgap = 0. |
| public | TilePane(double
the amount of horizontal space between each tile hgap, double the amount of vertical space between each tile vgap)Creates a horizontal TilePane layout with prefColumn = 5 and the specified hgap/vgap. |
| public | TilePane(Orientation
the direction the tiles should flow & wrap orientation, double the amount of horizontal space between each tile hgap, double the amount of vertical space between each tile vgap)Creates a TilePane layout with the specified orientation, hgap/vgap, and prefRows/prefColumns = 5. |
| public | |
| public | TilePane(Orientation
the direction the tiles should flow & wrap orientation, Node... The initial set of children for this pane. children)Creates a TilePane layout with the specified orientation, prefColumn/prefRows = 5 and hgap/vgap = 0. |
| public | |
| public | TilePane(Orientation
the direction the tiles should flow & wrap orientation, double the amount of horizontal space between each tile hgap, double the amount of vertical space between each tile vgap, Node... The initial set of children for this pane. children)Creates a TilePane layout with the specified orientation, hgap/vgap, and prefRows/prefColumns = 5. |
| Modifier and Type | Method and Description |
|---|---|
| public final ObjectProperty | Returns: the overall alignment of the tilepane's content within its width and heightThe overall alignment of the tilepane's content within its width and height. |
| public static void | |
| private int | |
| private double | |
| private double | |
| protected double | computeMinHeight(double width)
Overrides javafx. Computes the minimum height of this region. |
| protected double | computeMinWidth(double height)
Overrides javafx. Computes the minimum width of this region. |
| private int | |
| protected double | computePrefHeight(double forWidth)
Overrides javafx. 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. |
| protected double | computePrefWidth(double forHeight)
Overrides javafx. Computes the preferred width of this region for the given height. |
| private int | |
| private double | |
| private double | |
| public static Pos | Returns: the alignment position for the child or null if no alignment was setthe child node of a tilepane node)Returns the child's alignment constraint if set. |
| public final Pos | |
| private Pos | |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| public Orientation | getContentBias()
Overrides javafx. Returns the orientation of a node's resizing bias for layout purposes. |
| public List | getCssMetaData()
Overrides javafx. Implements javafx. This method should delegate to |
| public final double | |
| public static Insets | |
| public final Orientation | |
| public final int | |
| public final int | |
| public final double | |
| public final double | |
| public final Pos | |
| private Pos | |
| public final double | |
| public final double | |
| public final double | |
| public final DoubleProperty | Returns: the amount of horizontal space between each tile in a rowThe amount of horizontal space between each tile in a row. |
| private void | |
| private void | |
| protected void | layoutChildren()
Overrides javafx. Invoked during the layout pass to layout the children in this
|
| public final ObjectProperty | |
| public final IntegerProperty | Returns: the preferred number of columns for a horizontal tilepaneThe preferred number of columns for a horizontal tilepane. |
| public final IntegerProperty | Returns: the preferred number of rows for a vertical tilepaneThe preferred number of rows for a vertical tilepane. |
| public final DoubleProperty | Returns: the preferred height of each tileThe preferred height of each tile. |
| public final DoubleProperty | |
| public void | requestLayout()
Overrides javafx. Requests a layout pass to be performed before the next scene is rendered. |
| public static void | setAlignment(Node
the child node of a tilepane node, Pos the alignment position for the child value)Sets the alignment for the child when contained by a tilepane. |
| public final void | |
| public final void | |
| public static void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final ObjectProperty | Returns: the default alignment of each child within its tileThe default alignment of each child within its tile. |
| public final ReadOnlyDoubleProperty | |
| public final ReadOnlyDoubleProperty | |
| public final DoubleProperty | Returns: the amount of vertical space between each tile in a columnThe amount of vertical space between each tile in a column. |
| _tileHeight | back to summary |
|---|---|
| private double _tileHeight | |
| _tileWidth | back to summary |
|---|---|
| private double _tileWidth | |
| actualColumns | back to summary |
|---|---|
| private int actualColumns | |
| actualRows | back to summary |
|---|---|
| private int actualRows | |
| alignment | back to summary |
|---|---|
| private ObjectProperty<Pos> alignment | |
| ALIGNMENT_CONSTRAINT | back to summary |
|---|---|
| private static final String ALIGNMENT_CONSTRAINT | |
| hgap | back to summary |
|---|---|
| private DoubleProperty hgap | |
| MARGIN_CONSTRAINT | back to summary |
|---|---|
| private static final String MARGIN_CONSTRAINT | |
| marginAccessor | back to summary |
|---|---|
| private static final Callback<Node, Insets> marginAccessor | |
| orientation | back to summary |
|---|---|
| private ObjectProperty<Orientation> orientation | |
| prefColumns | back to summary |
|---|---|
| private IntegerProperty prefColumns | |
| prefRows | back to summary |
|---|---|
| private IntegerProperty prefRows | |
| prefTileHeight | back to summary |
|---|---|
| private DoubleProperty prefTileHeight | |
| prefTileWidth | back to summary |
|---|---|
| private DoubleProperty prefTileWidth | |
| tileAlignment | back to summary |
|---|---|
| private ObjectProperty<Pos> tileAlignment | |
| tileHeight | back to summary |
|---|---|
| private TilePane. | |
| tileWidth | back to summary |
|---|---|
| private TilePane. | |
| vgap | back to summary |
|---|---|
| private DoubleProperty vgap | |
| TilePane | back to summary |
|---|---|
| public TilePane() Creates a horizontal TilePane layout with prefColumn = 5 and hgap/vgap = 0. | |
| TilePane | back to summary |
|---|---|
| public TilePane(Orientation orientation) Creates a TilePane layout with the specified orientation, prefColumn/prefRows = 5 and hgap/vgap = 0.
| |
| TilePane | back to summary |
|---|---|
| public TilePane(double hgap, double vgap) Creates a horizontal TilePane layout with prefColumn = 5 and the specified hgap/vgap.
| |
| TilePane | back to summary |
|---|---|
| public TilePane(Orientation orientation, double hgap, double vgap) Creates a TilePane layout with the specified orientation, hgap/vgap, and prefRows/prefColumns = 5.
| |
| TilePane | back to summary |
|---|---|
| public TilePane(Node... children) Creates a horizontal TilePane layout with prefColumn = 5 and hgap/vgap = 0.
| |
| TilePane | back to summary |
|---|---|
| public TilePane(Orientation orientation, Node... children) Creates a TilePane layout with the specified orientation, prefColumn/prefRows = 5 and hgap/vgap = 0.
| |
| TilePane | back to summary |
|---|---|
| public TilePane(double hgap, double vgap, Node... children) Creates a horizontal TilePane layout with prefColumn = 5 and the specified hgap/vgap.
| |
| TilePane | back to summary |
|---|---|
| public TilePane(Orientation orientation, double hgap, double vgap, Node... children) Creates a TilePane layout with the specified orientation, hgap/vgap, and prefRows/prefColumns = 5.
| |
| alignmentProperty | back to summary |
|---|---|
| public final ObjectProperty The overall alignment of the tilepane's content within its width and height. For a horizontal tilepane, each row will be aligned within the tilepane's width using the alignment's hpos value, and the rows will be aligned within the tilepane's height using the alignment's vpos value. For a vertical tilepane, each column will be aligned within the tilepane's height using the alignment's vpos value, and the columns will be aligned within the tilepane's width using the alignment's hpos value.
| |
| clearConstraints | back to summary |
|---|---|
| public static void clearConstraints(Node child) Removes all tilepane constraints from the child node.
| |
| computeColumns | back to summary |
|---|---|
| private int computeColumns(double width, double tilewidth) | |
| computeContentHeight | back to summary |
|---|---|
| private double computeContentHeight(int rows, double tileheight) | |
| computeContentWidth | back to summary |
|---|---|
| private double computeContentWidth(int columns, double tilewidth) | |
| computeMinHeight | back to summary |
|---|---|
| protected double computeMinHeight(double width) Overrides javafx. Doc from javafx. Computes the minimum height of this region. Returns the sum of the top and bottom insets by default. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computeMinWidth | back to summary |
|---|---|
| protected double computeMinWidth(double height) Overrides javafx. Doc from javafx. Computes the minimum width of this region. Returns the sum of the left and right insets by default. region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| computeOther | back to summary |
|---|---|
| private int computeOther(int numNodes, int numCells) | |
| computePrefHeight | back to summary |
|---|---|
| protected double computePrefHeight(double forWidth) Overrides javafx. Doc from javafx. 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. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computePrefWidth | back to summary |
|---|---|
| protected double computePrefWidth(double forHeight) Overrides javafx. Doc from javafx. Computes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| computeRows | back to summary |
|---|---|
| private int computeRows(double height, double tileheight) | |
| computeTileHeight | back to summary |
|---|---|
| private double computeTileHeight() | |
| computeTileWidth | back to summary |
|---|---|
| private double computeTileWidth() | |
| getAlignment | back to summary |
|---|---|
| public static Pos getAlignment(Node node) Returns the child's alignment constraint if set. | |
| getAlignment | back to summary |
|---|---|
| public final Pos getAlignment() | |
| getAlignmentInternal | back to summary |
|---|---|
| private Pos getAlignmentInternal() | |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getContentBias | back to summary |
|---|---|
| public Orientation getContentBias() Overrides javafx. Doc from javafx. Returns the orientation of a node's resizing bias for layout purposes. If the node type has no bias, returns null. If the node is resizable and it's height depends on its width, returns HORIZONTAL, else if its width depends on its height, returns VERTICAL. Resizable subclasses should override this method to return an appropriate value.
| |
| getCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Implements javafx. Doc from javafx. This method should delegate to
| |
| getHgap | back to summary |
|---|---|
| public final double getHgap() | |
| getMargin | back to summary |
|---|---|
| public static Insets getMargin(Node node) Returns the child's margin constraint if set. | |
| getOrientation | back to summary |
|---|---|
| public final Orientation getOrientation() | |
| getPrefColumns | back to summary |
|---|---|
| public final int getPrefColumns() | |
| getPrefRows | back to summary |
|---|---|
| public final int getPrefRows() | |
| getPrefTileHeight | back to summary |
|---|---|
| public final double getPrefTileHeight() | |
| getPrefTileWidth | back to summary |
|---|---|
| public final double getPrefTileWidth() | |
| getTileAlignment | back to summary |
|---|---|
| public final Pos getTileAlignment() | |
| getTileAlignmentInternal | back to summary |
|---|---|
| private Pos getTileAlignmentInternal() | |
| getTileHeight | back to summary |
|---|---|
| public final double getTileHeight() | |
| getTileWidth | back to summary |
|---|---|
| public final double getTileWidth() | |
| getVgap | back to summary |
|---|---|
| public final double getVgap() | |
| hgapProperty | back to summary |
|---|---|
| public final DoubleProperty hgapProperty() The amount of horizontal space between each tile in a row.
| |
| invalidateTileHeight | back to summary |
|---|---|
| private void invalidateTileHeight() | |
| invalidateTileWidth | back to summary |
|---|---|
| private void invalidateTileWidth() | |
| layoutChildren | back to summary |
|---|---|
| protected void layoutChildren() Overrides javafx. Doc from javafx. Invoked during the layout pass to layout the children in this
Subclasses should override this function to layout content as needed.
| |
| orientationProperty | back to summary |
|---|---|
| public final ObjectProperty The orientation of this tilepane. A horizontal tilepane lays out children in tiles, left to right, wrapping tiles at the tilepane's width boundary. A vertical tilepane lays out children in tiles, top to bottom, wrapping at the tilepane's height. The default is horizontal.
| |
| prefColumnsProperty | back to summary |
|---|---|
| public final IntegerProperty prefColumnsProperty() The preferred number of columns for a horizontal tilepane. This value is used only to compute the preferred size of the tilepane and may not reflect the actual number of rows, which may change if the tilepane is resized to something other than its preferred height. This property is ignored for a vertical tilepane. It is recommended that the application initialize this value for a horizontal tilepane.
| |
| prefRowsProperty | back to summary |
|---|---|
| public final IntegerProperty prefRowsProperty() The preferred number of rows for a vertical tilepane. This value is used only to compute the preferred size of the tilepane and may not reflect the actual number of rows, which may change if the tilepane is resized to something other than its preferred height. This property is ignored for a horizontal tilepane. It is recommended that the application initialize this value for a vertical tilepane.
| |
| prefTileHeightProperty | back to summary |
|---|---|
| public final DoubleProperty prefTileHeightProperty() The preferred height of each tile. If equal to USE_COMPUTED_SIZE (the default) the tile height will be automatically recomputed by the tilepane when the preferred size of children changes to accommodate the tallest child. If the application sets this property to value greater than 0, then tiles will be set to that height and the tilepane will attempt to resize children to fit within that height (if they are resizable and their min-max height range allows it).
| |
| prefTileWidthProperty | back to summary |
|---|---|
| public final DoubleProperty prefTileWidthProperty() The preferred width of each tile. If equal to USE_COMPUTED_SIZE (the default) the tile width will be automatically recomputed by the tilepane when the preferred size of children changes to accommodate the widest child. If the application sets this property to value greater than 0, then tiles will be set to that width and the tilepane will attempt to resize children to fit within that width (if they are resizable and their min-max width range allows it).
| |
| requestLayout | back to summary |
|---|---|
| public void requestLayout() Overrides javafx. Doc from javafx. Requests a layout pass to be performed before the next scene is rendered. This is batched up asynchronously to happen once per "pulse", or frame of animation. If this parent is either a layout root or unmanaged, then it will be added directly to the scene's dirty layout list, otherwise requestParentLayout will be invoked.
| |
| setAlignment | back to summary |
|---|---|
| public static void setAlignment(Node node, Pos value) Sets the alignment for the child when contained by a tilepane. If set, will override the tilepane's default alignment for children within their 'tiles'. Setting the value to null will remove the constraint. | |
| setAlignment | back to summary |
|---|---|
| public final void setAlignment(Pos value) | |
| setHgap | back to summary |
|---|---|
| public final void setHgap(double value) | |
| setMargin | back to summary |
|---|---|
| public static void setMargin(Node node, Insets value) Sets the margin for the child when contained by a tilepane. If set, the tilepane will layout the child with the margin space around it. Setting the value to null will remove the constraint. | |
| setOrientation | back to summary |
|---|---|
| public final void setOrientation(Orientation value) | |
| setPrefColumns | back to summary |
|---|---|
| public final void setPrefColumns(int value) | |
| setPrefRows | back to summary |
|---|---|
| public final void setPrefRows(int value) | |
| setPrefTileHeight | back to summary |
|---|---|
| public final void setPrefTileHeight(double value) | |
| setPrefTileWidth | back to summary |
|---|---|
| public final void setPrefTileWidth(double value) | |
| setTileAlignment | back to summary |
|---|---|
| public final void setTileAlignment(Pos value) | |
| setVgap | back to summary |
|---|---|
| public final void setVgap(double value) | |
| tileAlignmentProperty | back to summary |
|---|---|
| public final ObjectProperty The default alignment of each child within its tile. This may be overridden on individual children by setting the child's alignment constraint.
| |
| tileHeightProperty | back to summary |
|---|---|
| public final ReadOnlyDoubleProperty tileHeightProperty() The actual height of each tile. This property is read-only.
| |
| tileWidthProperty | back to summary |
|---|---|
| public final ReadOnlyDoubleProperty tileWidthProperty() The actual width of each tile. This property is read-only.
| |
| vgapProperty | back to summary |
|---|---|
| public final DoubleProperty vgapProperty() The amount of vertical space between each tile in a column.
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final List | |
| private static final CssMetaData | |
| private static final CssMetaData |
| Access | Constructor and Description |
|---|---|
| private |
| ALIGNMENT | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Pos> ALIGNMENT | |
| HGAP | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Number> HGAP | |
| ORIENTATION | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Orientation> ORIENTATION | |
| PREF_COLUMNS | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Number> PREF_COLUMNS | |
| PREF_ROWS | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Number> PREF_ROWS | |
| PREF_TILE_HEIGHT | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Number> PREF_TILE_HEIGHT | |
| PREF_TILE_WIDTH | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Number> PREF_TILE_WIDTH | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| TILE_ALIGNMENT | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Pos> TILE_ALIGNMENT | |
| VGAP | back to summary |
|---|---|
| private static final CssMetaData<TilePane, Number> VGAP | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private boolean | |
| private double |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public abstract double | |
| public double | get()
Implements javafx. Returns the current value of this |
| public Object | getBean()
Implements javafx. Returns the |
| public String | getName()
Implements javafx. Returns the name of this property. |
| public void |
| name | back to summary |
|---|---|
| private final String name | |
| valid | back to summary |
|---|---|
| private boolean valid | |
| value | back to summary |
|---|---|
| private double value | |
| TileSizeProperty | back to summary |
|---|---|
| pack-priv TileSizeProperty(String name, double initSize) | |
| compute | back to summary |
|---|---|
| public abstract double compute() | |
| get | back to summary |
|---|---|
| public double get() Implements javafx. Doc from javafx. Returns the current value of this
| |
| getBean | back to summary |
|---|---|
| public Object getBean() Implements javafx. Doc from javafx. Returns the
| |
| getName | back to summary |
|---|---|
| public String getName() Implements javafx. Doc from javafx. Returns the name of this property. If the property does not have a name,
this method returns an empty
| |
| invalidate | back to summary |
|---|---|
| public void invalidate() | |