MenuBarSkin: exception initializing in a background thread

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • jfx25
    • Affects Version/s: jfx23
    • Component/s: javafx
    • b11

      MenuButtonSkin fails to initialize in a background thread, throwing an IllegalStateException calling Toolkit.getToolkit().getSystemMenu().isSupported() in MenuBarSkin:822

      ```
          @Test
          public void menuBar() {
              MenuBar c = new MenuBar();
              c.setSkin(new MenuBarSkin(c));
          }
      ```

      ## Root Cause

      MenuBarSkin.rebuildUI() relies on Toolkit.getToolkit().getSystemMenu().isSupported() which can only be invoked in the FX application thread.

      ## Possible Solution

      Postpone rebuildUI() until after the menu gets added to a Window (similarly to Chart fix https://bugs.openjdk.org/browse/JDK-8349091 ).

            Assignee:
            Andy Goryachev
            Reporter:
            Andy Goryachev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: