BorderPane is separated into five different areas.
The border areas (
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
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