13.JavaFx BorderPane布局类

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

/**
 * BorderPane 布局类
 */
public class Demo15 extends Application {

    @Override
    public void start(Stage stage) throws Exception {

        AnchorPane anchorPane1 = new AnchorPane();
        anchorPane1.setPrefWidth(100);
        anchorPane1.setPrefHeight(100);
        anchorPane1.setStyle("-fx-background-color: #EE6AA7");

        AnchorPane anchorPane2 = new AnchorPane();
        anchorPane2.setPrefWidth(100);
        anchorPane2.setPrefHeight(100);
        anchorPane2.setStyle("-fx-background-color: #98FB98");

        AnchorPane anchorPane3 = new AnchorPane();
        anchorPane3.setPrefWidth(100);
        anchorPane3.setPrefHeight(100);
        anchorPane3.setStyle("-fx-background-color: #A0522D");

        AnchorPane anchorPane4 = new AnchorPane();
        anchorPane4.setPrefWidth(100);
        anchorPane4.setPrefHeight(100);
        anchorPane4.setStyle("-fx-background-color: #1E90FF");

        AnchorPane anchorPane5 = new AnchorPane();
        anchorPane5.setPrefWidth(100);
        anchorPane5.setPrefHeight(100);
        anchorPane5.setStyle("-fx-background-color: #EEEE00");

        BorderPane borderPane = new BorderPane();
        borderPane.setStyle("-fx-background-color: #B23AEE");

        Button button = new Button("按钮");

//        borderPane.setTop(button);
        borderPane.setTop(anchorPane1);
//        borderPane.setBottom(anchorPane2);
        borderPane.setLeft(anchorPane3);
        borderPane.setRight(anchorPane4);
        borderPane.setCenter(anchorPane5);

//        borderPane.setPadding(new Insets(10));
//        BorderPane.setMargin(anchorPane1,new Insets(10));
        BorderPane.setAlignment(anchorPane1, Pos.BOTTOM_CENTER);

        Scene scene = new Scene(borderPane);
        stage.setScene(scene);
        stage.setTitle("javafx");
        stage.setWidth(800);
        stage.setHeight(800);
        stage.show();

    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值