javafx Layouts BorderPane

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The BorderPane is separated into five different areas.

The different areas of a BorderPane

The border areas (Top, Right, Bottom, Left) have preferred sized based on their content. By default they will only take what they need, while the Center area will take any remaining space. When the border areas are empty, they do not take up any space.

Each area can contain only one element. It can be added using the methods setTop(Node), setRight(Node), setBottom(Node), setLeft(Node), setCenter(Node). You can use other layouts to put more than one element into a single area.

//BorderPane example
BorderPane pane = new BorderPane();

Label top = new Label("Top");

Label right = new Label("Right");

HBox bottom = new HBox();
bottom.getChildren().addAll(new Label("First"), new Label("Second"));

VBox left = new VBox();
left.getChildren().addAll(new Label("Upper"), new Label("Lower"));

StackPane center = new StackPane();
center.getChildren().addAll(new Label("Lorem"), new Label("ipsum"));

pane.setTop(top);        //The text "Top"
pane.setRight(right);    //The text "Right"
pane.setBottom(bottom);  //Row of two texts
pane.setLeft(left);      //Column of two texts
pane.setCenter(center);  //Two texts on each other


Got any javafx Question?