Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8254669

[macos] MenuBar.useSystemMenuBarProperty Does Not Work

    XMLWordPrintable

Details

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Tested on macOS Catalina and Big Sur. Used jdk-15_osx-x64_bin.dmg form Oracle site as Java Runtime. Used latest JavaFX and sample from https://github.com/openjfx/samples/tree/master/HelloFX/Maven

      A DESCRIPTION OF THE PROBLEM :
      Setting a MenuBar to use the system menu bar does not work on macOS 10.15 Catalina or Big Sur. Setting MenuBar.useSystemMenuBarProperty(true) causes the menu bar to completely lock up - not only does it not work, but the menu becomes completely non-responsive to user input.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the Hello World sample - for example the Maven example above. Create a one line MenuBar, Menu, and MenuItem and add to the scene. If the MenuBar.useSystemMenuBarProperty is left to the default false, works fine. Setting the useSystemMenuBarProperty to true causes the menu bar to fail.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The system menu bar should work as expected - for example, the drop down should display normally and selecting an item should send back an event.
      ACTUAL -
      The system menu bar locks up. Even the standard menu items (e.g. the default java menu item) lock up.

      ---------- BEGIN SOURCE ----------
      package com.gluonhq;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.stage.Stage;

      public class HelloFX extends Application {

          public void start(Stage stage) {

              MenuBar menuBar = new MenuBar();
              Menu menu = new Menu("Hello");
              menuBar.getMenus().add(menu);
              MenuItem menuItem = new MenuItem("World");
              menu.getItems().add(menuItem);

              menuBar.setUseSystemMenuBar(true);
              Scene scene = new Scene(menuBar, 640, 480);
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround found. I did some experimentation with https://github.com/codecentric/NSMenuFX and the feedback was that that project was monkeying around with inappropriate internals.

      https://github.com/openjfx/javafx-maven-plugin/issues/107

      Haven't had a chance to get that project working, not sure it will continue to work on future versions of Java and/or JavaFX.

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              pnarayanaswa Praveen Narayanaswamy
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: