JavaFX Pane

Pane

面板类主要有如下几种:栈面板类StackPane、边界面板类BorderPane、流式面板类
FlowPane、网格面板类GridePane、单行面板类HBox和单列面板类VBox等几种。
ps:一个节点只能添加到一个面板中

JavaFX CSS

sPane.setStyle("-fx-border-color: yellow;-fx-background-color: green");
bt1.setStyle("-fx-border-color: red");

StackPane

StackPane sPane = new StackPane();
sPane.getChildren().addAll(bt1,bt);

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;


public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
      StackPane sPane = new StackPane();
      Button bt = new Button("Button");
      bt.setStyle("-fx-border-color: blue");
      bt.setPrefSize(80,50);
      Button bt1 = new Button("Button1");
      bt1.setStyle("-fx-border-color: red");
      bt1.setPrefSize(100,80);
      bt.setRotate(-45);
      sPane.setRotate(45);
      sPane.setStyle("-fx-border-color: yellow;-fx-background-color: green");
      sPane.getChildren().addAll(bt1,bt);
      Scene sc = new Scene(sPane,180,100);
      primaryStage.setTitle("StackPane");
      primaryStage.setScene(sc);
      primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值