On Wed, 1 Jul 2026 19:44:43 GMT, Martin Fox <[email protected]> wrote:
>> This PR provides an API for replacing the application menu that JavaFX >> places in the system menu bar on macOS. The application menu is the one next >> to the Apple menu that is titled with the application's name and contains >> the Quit menu item. The JavaFX version of this menu has many limitations so >> this PR allows a developer to simply replace it outright. >> >> Technically there’s no reason to restrict this to only one menu so the API >> allows the developer to specify an observable list of Menus known as the >> common system menus. Like the current application menu the common menus are >> present for all JavaFX windows and remain present even if all windows lose >> focus. Any per-window menus provided by a MenuBar with useSystemMenuBar set >> will appear alongside the common system menus. >> >> In addition the PR provides some calls that allow a developer to implement >> the Hide <app name>, Hide Others, and Show All menu items that are expected >> in the application menu. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Martin Fox has updated the pull request with a new target base due to a merge > or a rebase. The incremental webrev excludes the unrelated changes brought in > by the merge/rebase. The pull request contains eight additional commits since > the last revision: > > - Merge remote-tracking branch 'upstream/master' into commonmenus > - Tweaked testing utility that searches NSApp.mainMenu, added tests > - Merge remote-tracking branch 'upstream/master' into commonmenus > - New way of testing system menu bar, updated tests > - Merge remote-tracking branch 'upstream/master' into commonmenus > - Quick fix for a javadoc issue. > - Merge remote-tracking branch 'upstream/master' into commonmenus > - Specify a list of menus that are always present in the system menu bar Speaking of the system menu and `ApplicationServices`, macos-only features, and the new API that are being brought in to the classes common to all the platforms: could there be a better way to express the desired functionality? So on mac, we have a number of features that are only available there - the system menu, the notch, the key bar that I think they got rid of already. One way to support these (used currently by javafx) is to add these API into common classes (`MenuBar.setUseSystemMenuBar()` for example) which would be no-op on other platforms. The other possibility is to provide a proxy interface through which these platform-specific APIs will be available on the supported platform, and it will be null on all others. Example: AppleSystemMenu m = Lookup.get(AppleSystemMenu.class); if(m == null) { // not available, probably not a macos } else { // macos system menu functionality is available, use it m.getSystemMenuBar(); m.getHideAllAction(); // etc. } These proxies can be multiplied as the platform evolves (notch? brain interface?), or even provided by a third party. In other words, the common functionality is provided by the base classes, and the platform- and version- specific functionality - by the corresponding proxies. What do you think? ------------- PR Comment: https://git.openjdk.org/jfx/pull/1881#issuecomment-4867013217
