Proposing an API for replacing the application menu on macOS
Martin Fox
martinfox656 at gmail.com
Tue Sep 2 15:33:50 UTC 2025
I’ve submitted a draft PR (#1881) with an API that allows a JavaFX developer to replace the application menu on macOS. This is the first menu in the system menu bar, the one that is titled with the application’s name and sits next to the Apple menu. Currently JavaFX builds this menu internally and it’s not customizable in any way (it can’t even be localized). This menu used to require special handling at the OS level but those days are long gone so there’s no technical reason a developer can’t just replace it wholesale.
The implementation is more straightforward than the documentation. JavaFX has never documented the presence of this menu and it exhibits some unique behavior. The application menu is always present even for JavaFX applications that don’t use the system menu bar or MenuBars in general. And unlike other JavaFX menus the application menu is accessible when all windows are iconified. The application menu lives in a separate space from the per-window menus and we now need to document that.
The new API allows a developer to replace the application menu with a list of menus which I call the common menus. Like the current application menu the common menus are always present. Any menus provided by a MenuBar with setUseSystemMenu set to true will appear alongside the common menus. In theory a JavaFX developer could go full Mac-like and install a single set of common menus at application launch and forego per-window menus altogether. Or they could just replace the application menu and continue using per-window MenuBar’s in keeping with the JavaFX idiom.
The application menu contains some items which require platform support (Hide, Hide Others, and Show All) and I wasn’t sure where to put those calls. I’m still not sure. I welcome feedback on that and any other part of this proposed API.
More information about the openjfx-dev
mailing list