简体   繁体   English

我的菜单栏不在 window 的顶部?

[英]My MenuBar isn't on the top of my window?

Hello I want to up my menuBar on the top of the window like all sofware?您好,我想像所有软件一样在 window 顶部设置我的 menuBar?

在此处输入图像描述

This is the code:这是代码:


    @Override
    public void start(Stage primaryStage) throws Exception{

        Image image = new Image("GUI/Images/grass_block_side.png");
        ImageView imageView = new ImageView(image);
        imageView.setPreserveRatio(true);
        imageView.setFitHeight(128);
        FlowPane root = new FlowPane();
        Button btnConvert = new Button("Convert=>");
        MenuBar menuBar = new MenuBar();
        menuBar.setUseSystemMenuBar(true);
        Menu fichier = new Menu("Fichier");
        menuBar.getMenus().add(fichier);
        ListView<Material> ListViewMateriel = new ListView<>();
        ObservableList<Material> items = FXCollections.observableArrayList ();
        ListViewMateriel.setItems(items);
        root.getChildren().addAll(imageView,menuBar,btnConvert,ListViewMateriel);
        root.setPadding(new Insets(15,15,15,15));
        root.setHgap(10);
        root.setVgap(20);

If I could recommend using Scene Builder, everything is done there with such ease it's ridiculous.如果我可以推荐使用 Scene Builder,那么一切都可以轻松完成,这太荒谬了。 There you could anchor it to the top, left, and right, and that would do the trick.在那里,您可以将其锚定在顶部、左侧和右侧,这样就可以了。 Just a recommendation只是一个建议

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM