Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MenuBar not working on launch #8

Closed
twiedow opened this issue Dec 11, 2020 · 4 comments
Closed

MenuBar not working on launch #8

twiedow opened this issue Dec 11, 2020 · 4 comments

Comments

@twiedow
Copy link

twiedow commented Dec 11, 2020

I have the same issue like described here:
https://stackoverflow.com/questions/22569046/how-to-make-an-os-x-menubar-in-javafx/39627830#39627830

I cannot open the menu bar until I switch to another app and back to my JavaFX app. Then everything works as expected.

Do you have an idea what the problem is here?

I use OpenJDK 15 and JavaFX 15. I add a default app menu like this:

            var tk = MenuToolkit.toolkit();
            var defaultApplicationMenu = tk.createDefaultApplicationMenu("BCM");
            tk.setApplicationMenu(defaultApplicationMenu);

Then on a stage I'm adding a menu bar like this:

        var fileMenu = MenuBarUtil.createMenu(MenuType.file);
        MenuBarUtil.addMenuItemToMenu(fileMenu, MenuItemType.fileClose, this::close);

        var menuBar = new MenuBar();
        menuBar.setUseSystemMenuBar(true);
        menuBar.getMenus().add(fileMenu);

        gridPane.add(menuBar, 0, 0);

The helper class just adds some menu items with some key code combinations as accelerators.

@0x4a616e
Copy link
Owner

Hi @twiedow, thanks for the report. That seems to be a JavaFX-related issue and might not have something to do with NSMenuFX: https://bugs.openjdk.java.net/browse/JDK-8233678 Can you maybe check if the same issue is also occurring without NSMenuFX?

@vewert
Copy link

vewert commented Dec 11, 2020

I had noticed a similar behaviour, but only when running through the IDE (IntelliJ). In my case, however, after building it into a mac .app and running it, the menu seemed to work fine. Note: I use https://github.com/beryx/badass-jlink-plugin (which uses jlink and jpackage) to build it into a mac app.

@0x4a616e
Copy link
Owner

I have the same issue when I run the application from IntelliJ. But for me, this happens regardless of wether or not I use NSMenuFX... So to me it looks like this issue is rooted somewhere in JFX 😞

@0x4a616e
Copy link
Owner

The respective PR was merged just a few days ago: openjdk/jfx#361
So I hope we'll see a fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants