- 将容器空间分成五个区域:顶部(Top)、底部(Bottom)、左侧(Left)、右侧(Right)和中心(Center)。每个区域都可以放置一个节点(Node),比如另一个布局容器或UI控件
- BorderPane中的一些区域可以为空,只设置需要的区域即可
- 顶部和底部默认是横向扩展全宽的
- 左右两侧则会扩展到足够容纳内容的高度
- 中心区域通常用来放置主要的内容,默认会填充剩余的空间

实现方式
Java实现
BorderPane pane = new BorderPane();
pane.setTop(new Label("top"));
pane.setCenter(new Label("center"));
pane.setBottom(new Label("bottom"));
pane.setLeft(new Label("left"));
pane.setRight(new Label("right"));
pane.setPadding(new Insets(5, 10, 10, 5));
FXML实现
<BorderPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" prefHeight="400.0" prefWidth="600.0">
<top>
<Button text="top"/>
</top>
<center>
<Button text="center"/>
</center>
<bottom>
<Button text="bottom"/>
</bottom>
<left>
<Button text="left"/>
</left>
<right>
<Button text="right"/>
</right>
</BorderPane>
综合案例
BorderPane pane = new BorderPane();
MenuBar menuBar = new MenuBar();
menuBar.setStyle("-fx-background-color: pink;");
Menu file = new Menu("文件");
file.getItems().add(new Menu("新建"));
file.getItems().add(new Menu("打开"));
menuBar.getMenus().add(file);
menuBar.getMenus(