JavaFX BorderPane

2024 年 8 月 29 日 | 阅读 2 分钟

BorderPane 将节点排列在屏幕的左侧、右侧、中间、顶部和底部。它由 javafx.scene.layout.BorderPane 类表示。这个类提供了各种方法,例如 setRight(),setLeft(),setCenter(),setBottom()setTop(),它们用于设置指定节点的位置。我们需要实例化 BorderPane 类来创建 BorderPane 布局。

性质

下表给出了 BorderPane 类的属性及其 setter 方法。

类型属性设置器方法描述
节点底部setBottom()将节点添加到屏幕底部
节点中心setCentre()将节点添加到屏幕中心
节点setLeft()将节点添加到屏幕左侧
节点setRight()将节点添加到屏幕右侧
节点顶部setTop()将节点添加到屏幕顶部

构造函数

类中有以下构造函数。

  1. BorderPane() : 创建空布局
  2. BorderPane(Node Center) : 创建带有中心节点的布局
  3. BorderPane(Node Center, Node top, Node right, Node bottom, Node left) : 创建包含所有节点的布局

示例


JavaFX BorderPane Output
下一主题JavaFX HBox