这是使 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();
您可以在不使用bind的情况下实现相同的功能,仅使用边框窗格 http://docs.oracle.com/javafx/2.0/api/javafx/scene/layout/BorderPane.html而不是组
final BorderPane root = new BorderPane();
// construct your VBox
root.setCenter(vbox);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)