JavaFX 8 设置 TextArea 大小未满

JavaFX 8 set TextArea size not full

我程序中的TextArea只扩展全宽但不扩展全高。

public class Example extends Application {

@Override
public void start(Stage primaryStage) {

   TextArea textArea = new TextArea();

   MenuBar menuBar = new MenuBar();

   Menu menuFile = new Menu("File"); //Menu File
   MenuItem fileItem = new MenuItem("Hi");  //Menu Item under file
   MenuItem exitItem = new MenuItem("Exit");
   menuFile.getItems().addAll(fileItem, exitItem); //Add menu item "hi" to menuFile

    fileItem.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            System.out.println("Test");          //Add event
        }
    });

    exitItem.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            System.exit(0);
        }
    });



   Menu menuEdit = new Menu("Edit");

   Menu menuView = new Menu("View");








   // Button btn = new Button(); //Declare the new button
   // TextArea txt = new TextArea(); //Declare new text area


    menuBar.getMenus().addAll(menuFile, menuEdit, menuView); //Add menuItems to menu
    Scene scene = new Scene(new VBox(), 600, 350);   //Set scene dimension and VBox

    ((VBox) scene.getRoot()).getChildren().addAll(menuBar, textArea);


    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}
public static void main(String[] args) { //Main gets ignored
    launch(args);
}
}

[1]: http://i.stack.imgur.com/8GT5a.png [/1]

我程序中的文本区域不会一直延伸到底部,我知道这与我的 VBox 有关,但我应该添加什么才能使 TextArea 延伸?

尝试在创建 textArea 后添加:

VBox.setVgrow(textArea, Priority.ALWAYS);