VBox 内的 TextArea 未垂直缩放

TextArea inside VBox is not scaling vertically

我正在使用 JavaFX 创建一个简单的 GUI,但我偶然发现了一个问题。每当我垂直调整 GUI 大小时。我的 TextAre 不会自行调整大小,尽管它应该填充 space.

MainClass

public class Main extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        mainWindow(primaryStage);
    }

    private void mainWindow(Stage primaryStage) {
        try {
            FXMLLoader loader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
            loader.setController(this);
            Parent root = loader.load();

            primaryStage.setScene(new Scene(root));
            primaryStage.setMinWidth(270);
            primaryStage.setMinHeight(450);
            primaryStage.show();
        } catch (IOException ignored) {}
    }
}

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.input.*?>
<?import javafx.scene.layout.*?>

<BorderPane minHeight="400.0" minWidth="240.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1"
            xmlns:fx="http://javafx.com/fxml/1">
   <center>
      <VBox>
         <children>
            <GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="110.0" prefWidth="240.0">

            </GridPane>
            <VBox>
               <children>
                  <Label text="Results:" />
                  <TextArea fx:id="resultArea" minHeight="200.0" VBox.vgrow="ALWAYS" />
               </children>
               <VBox.margin>
                  <Insets left="5.0" right="5.0" />
               </VBox.margin></VBox>
         </children>
      </VBox>
   </center>
</BorderPane>

我必须添加什么,我的 TextArea 会自动调整垂直大小?

主要问题是 VBox 持有你的 TextArea 只会占用它需要的 space,所以当你调整 VBox 的大小时它不会扩展=25=].

要解决此问题,您需要在 Scene Builder 中将 VBox 的 VGrow 属性 设置为 ALWAYS

或者您的 FXML:

<VBox VBox.vgrow="ALWAYS">