RFR: 8091629: [Mac] Support the automatic hiding of the "java" menu bar item when using the system menu bar

Martin Fox mfox at openjdk.org
Fri Mar 14 18:39:43 UTC 2025


On the Mac the application menu (the one to the right of the Apple logo menu) is created by JavaFX and there is no public API to customize or localize it. This PR allows a client to get rid of it and replace it with an entirely custom JavaFX Menu.

Prior to OS X 10.6 (Snow Leopard) the application menu required special handling. Nowadays it's just the first item in the NSApp's mainMenu. The only restriction is that the OS ignores the item's title and instead uses the application's name as specified in the CFBundle.

This PR is a work-in-progress/trial balloon. It provides a new property on the MenuBar that controls whether the system will use the default menus. It also supplies the calls necessary to implement the standard menu items "Hide <application>", "Hide Others", and "Show All" which need to be routed to native calls on the NSApplication object. A manual test app is available in tests/manual/controls/DefaultAppMenu.java.

-------------

Commit messages:
 - Added stub TKSystemMenu routines
 - Fixed javadoc issue
 - Added manual test app
 - Added calls necessary to reproduce the Mac application menu.
 - Provide property to disable default menus in the system menu bar

Changes: https://git.openjdk.org/jfx/pull/1737/files
  Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1737&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8091629
  Stats: 417 lines in 11 files changed: 399 ins; 13 del; 5 mod
  Patch: https://git.openjdk.org/jfx/pull/1737.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1737/head:pull/1737

PR: https://git.openjdk.org/jfx/pull/1737


More information about the openjfx-dev mailing list