On the Mac the JavaFX core creates the application menu, the one immediately 
adjacent to the Apple menu in the menu bar. There is no JavaFX API to access it 
so a developer can’t localize the existing items or add additional ones (like 
About). We can’t easily provide access to it since it’s not built using public 
Controls. While thinking about how to fix this I realized the simplest approach 
would be to just remove it entirely and let the developer build their own.

Before macOS Snow Leopard (10.6, circa 2009) the application menu was created 
by the OS and you had to issue special calls to replace it. Now it’s simply the 
first item in the NSApplication’s mainMenu. If the system menu bar is enabled 
removing the built-in application menu simply shifts the JavaFX MenuBar menus 
over so the first menu becomes the application menu.

Unfortunately we would need to fill some holes in the JavaFX API to make this a 
useful solution. Currently the system tears down the system menu bar when a 
Stage is iconified and there’s no way to specify a menu bar to be displayed 
when there’s no Stage. There should be an API that allows a developer to 
provide a default menu bar to display in these situations. Any suggestions on 
what that would look like are welcome.

I pulled together a rough draft as a proof of concept 
(https://git.openjdk.org/jfx/pull/1737). It adds a new property to the MenuBar 
that allows the developer to shut off the default application menu. It also 
provides the calls necessary to implement the standard Hide, Hide Others, and 
Show All items that usually appear in the app menu.

Let me know if you have any thoughts or feedback.

Martin

Reply via email to