Javafx 应用程序顶部的菜单栏
我对JavaFX非常陌生,我有两种方法——一种是返回网格布局,另一种是返回带有菜单栏的HBox,但在我的一生中,我无法做到这一点,因此它不会重叠(我希望网格比它低几个像素)。我的启动方法中有以下代码:Javafx 应用程序顶部的菜单栏,javafx,javafx-8,Javafx,Javafx 8,我对JavaFX非常陌生,我有两种方法——一种是返回网格布局,另一种是返回带有菜单栏的HBox,但在我的一生中,我无法做到这一点,因此它不会重叠(我希望网格比它低几个像素)。我的启动方法中有以下代码: final Group rootGroup = new Group(); final Scene scene = new Scene(rootGroup); rootGroup.getChildren().add(addBar(stage.widthProperty())); r
final Group rootGroup = new Group();
final Scene scene = new Scene(rootGroup);
rootGroup.getChildren().add(addBar(stage.widthProperty()));
rootGroup.getChildren().add(addGridPane());
stage.setScene(scene);
stage.show();
如何修复此问题?您可以使用另一个布局管理器作为根目录。例如:
final VBox rootGroup = new Vbox();
然后,它的所有子项都将垂直对齐。HBox实际上不起作用,但我尝试了FlowPane,它的效果非常好。谢谢