相关疑难解决方法(0)

如何使VBox填充其父级的大小

这是使VBox填充其父级的正确方法:

    final Group root = new Group();
    final Scene scene = new Scene(root, 1000, 800, Color.BLACK);

    final VBox c = new VBox();
    c.setAlignment(Pos.TOP_CENTER);
    c.setSpacing(10); 
    c.setFillWidth(true);
    c.getChildren().add(...);
    c.getChildren().add(...);
    c.getChildren().add(...);

    c.prefWidthProperty().bind(scene.widthProperty());
    c.prefHeightProperty().bind(scene.heightProperty());

    root.getChildren().add(c);

    stage.setTitle("blah"); //$NON-NLS-1$
    stage.setScene(scene);
    stage.show();
Run Code Online (Sandbox Code Playgroud)

javafx-2

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

javafx-2 ×1