📅  最后修改于: 2020-10-14 05:49:35             🧑  作者: Mango
Vbox布局窗格不是将节点排列在水平行中,而是将节点排列在单个垂直列中。它由javafx.scene.layout.VBox类表示,该类提供了处理样式和节点之间距离的所有方法。为了在我们的应用程序中实现VBox布局,需要实例化此类。
此方法提供下表中描述的各种属性。
Property | Description | Setter Methods |
---|---|---|
Alignment | This property is for the alignment of the nodes. | setAlignement(Double) |
FillWidth | This property is of the boolean type. The Widtht of resizeable nodes can be made equal to the Width of the VBox by setting this property to true. | setFillWidth(boolean) |
Spacing | This property is to set some spacing among the nodes of VBox. | setSpacing(Double) |
package application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Label_Test extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Button btn1 = new Button("Button 1");
Button btn2 = new Button("Button 2");
VBox root = new VBox();
Scene scene = new Scene(root,200,200);
root.getChildren().addAll(btn1,btn2);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
输出: