简体   繁体   English

使用css在javafx中调整stackpane

[英]resize stackpane in javafx with css

i'm working with javaFx and i want resize my stackPane or add border, how can i do that? 我正在使用javaFx,我想调整我的stackPane或添加边框,我该怎么办? and how can i position it in the center or my window? 我怎么能把它放在中心或窗口?

this is my code: 这是我的代码:

 final HBox box =  new HBox();
        box.getStyleClass().add("box");
        final ToolBar outils = new ToolBar();
        final Button file = new Button("fichier");
        final Button as2 = new Button("AS2");
        final Button ftp = new Button("FTP");
        final Button arrow = new Button("Liaison");
        file.setGraphic(new ImageView("/images/file.png"));
        as2.setGraphic(new ImageView("/images/http.png"));
        ftp.setGraphic(new ImageView("/images/ftp.png"));
        arrow.setGraphic(new ImageView("/images/Arrow.png"));
        box.getChildren().addAll(file,as2,ftp,arrow);
        outils.getItems().addAll(box);



        // ma zone de dessin
        final StackPane paint = new StackPane();
          paint.setStyle("-fx-background-color: #FFFFFF;");
        paint.setPrefSize(0, 690);
        paint.getStyleClass().add("paint");

and this is my window : 这是我的窗口:

在此输入图像描述

tks TKS

try this ; 尝试这个 ; in your controller 在你的控制器中

@FXML StackPane pane; @FXML StackPane窗格;

public void Action(){
.
.
.
    pane.setPrefHeight(value);
    pane.setPrefWidth(value);
.
.
.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM