Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javafx标题窗格调整标题_Java_Javafx_Resize - Fatal编程技术网

Javafx标题窗格调整标题

Javafx标题窗格调整标题,java,javafx,resize,Java,Javafx,Resize,有没有办法将标题窗格的标题调整为GridPane的大小 下面是标题窗格的代码 // --- GridPane container final Label label = new Label("N/A"); TitledPane gridTitlePane = new TitledPane(); GridPane grid = new GridPane(); gridTitlePane.setStyle("-fx-background-color

有没有办法将标题窗格的标题调整为GridPane的大小

下面是标题窗格的代码

        // --- GridPane container
    final Label label = new Label("N/A");
    TitledPane gridTitlePane = new TitledPane();
    GridPane grid = new GridPane();

    gridTitlePane.setStyle("-fx-background-color: #336699;");
    gridTitlePane.setPrefSize(parentGrid.getPrefWidth(),parentGrid.getPrefHeight());
    gridTitlePane.setText("Statistik");
    gridTitlePane.setExpanded(false);
    //grid.setVgap(4);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(new TextField(), 1, 0);
    grid.add(new Label("Cc: "), 0, 1);
    grid.add(new TextField(), 1, 1);
    grid.add(new Label("Subject: "), 0, 2);
    grid.add(new TextField(), 1, 2);
    grid.add(new Label("Attachment: "), 0, 3);
    grid.add(label,1, 3);
                                                    gridTitlePane.setStyle("");
    gridTitlePane.setContent(grid);

    HBox hbox = new HBox();
    //HBox.setHgrow(gridTitlePane,Priority.ALWAYS);
    //HBox.setHgrow(grid,Priority.ALWAYS);
    hbox.getChildren().setAll(gridTitlePane);

您可以在css文件中为标题栏设置固定大小:

.titled-pane > .title {
    -fx-pref-height: 36.0;
}
或者您可以使用
节点的
查找(字符串)
功能设置高度

Platform.runLater(() -> {
            Pane title = (Pane) titlePane.lookup(".title");
             title.setPrefHeight(value);
             //or
             title.prefHeightProperty().bind(gridPane.heightProperty());
            });

您可以在css文件中为标题栏设置固定大小:

.titled-pane > .title {
    -fx-pref-height: 36.0;
}
或者您可以使用
节点的
查找(字符串)
功能设置高度

Platform.runLater(() -> {
            Pane title = (Pane) titlePane.lookup(".title");
             title.setPrefHeight(value);
             //or
             title.prefHeightProperty().bind(gridPane.heightProperty());
            });

我不能这样做吗
gridTitlePane.setStyle(“-fx宽度:100%”,“-fx高度:100%”
?我可以像IntelliJ idea输出窗口那样在运行时调整窗格的大小吗?我不能这样做吗
gridTitlePane.setStyle(“-fx宽度:100%”,“-fx高度:100%”
?我可以像IntelliJ idea输出窗口一样在运行时调整窗格的大小吗?