What layout should you choose in JavaFX ?

So, there are a lot of them and therefore I am going to write about each of them. This will be a small summary. This information is taken from JavaFX docs which is in a current state not that good. All information is taken from that site. Copy & Paste here. Copyright goes to Oracle, my favorite comapany.

BorderPane

  • 5 regions in which to place nodes: top, bottom, left, right, and center
  • regions can be any size
  • if you don’t need some of nodes, you don’t have to use it > no space allocation
  • for the “classic look”
  • If the window is larger than the space needed for the contents of each region, the extra space is given to the center region by default.

  • If the window is smaller than the space needed for the contents of each region, the regions might overlap.

HBox

  • arranging a series of nodes in a single row
  • style, spacing and padding can be set

VBox

  • nodes arranged in a single column (Vertical box & Horizontal box)
  • style, spacing and padding can be set

StackPane

  • places all of the nodes within a single stack with each new node added on top of the previous node
  • easy way to overlay text on a shape or image

GridPane

  • flexible grid of rows and columns in which to lay out nodes
  • nodes can be placed in any cell in the grid and can span cells as needed
  • creating forms or any layout that is organized in rows and columns
  • as the window is resized, the nodes within the grid pane are resized according to their layout constraints.
  • gap property, padding property, vertical and horizontal alignment properties can be set

FlowPane

  • nodes are laid out consecutively and wrap at the boundary set for the pane
  • nodes can flow vertically (in columns) or horizontally (in rows)

TilePane

  • similar to a flow pane > places all of the nodes in a grid in which each cell, or tile, is the same size
  • Use the prefColumns and prefRows properties to establish the preferred size of the tile pane
  • gap and padding property can be set

AnchorPane

  • anchor nodes to the top, bottom, left side, right side, or center of the pane
  • nodes maintain their position relative to their anchor point
  • nodes can be anchored to more than 1 position and more than 1 node can be anchored to the same position
  • probably most universal