Wednesday, June 13, 2012

JavaFX 2 Layouts: TilePane

Hello and welcome back to JavaFX 2 Layouts tutorial series. This is a tutorial about TilePane. The TilePane layout pane places all of the nodes in a grid in which each cell, or tile, is the same size. Nodes can be laid out horizontally (in rows) or vertically (in columns). Gap properties can be set to manage the spacing between the rows and columns. The padding property can be set to manage the distance between the nodes and the edges of the pane. Below you can take a look how our example will look in the end.

Here is the code:


We could modify a little bit our example by using the prefColumns or prefRows properties to establish the preferred size of the tile pane. Below you can take a look how our example will look after using prefColumns properties.





If you want, you can check other  tutorials from JavaFX 2 Layouts series:




1 comments:

  1. "tilePane.getChildren().add(btn);"

    Ain´t it better to collect them all into a List inside the loop and add them all to the Stage at once by using addAll?

    ReplyDelete