RFR: 8359108: Mac - When Swing starts First, native application menu doesn't work for JavaFX

Pabulaner IV duke at openjdk.org
Mon Jun 23 20:50:34 UTC 2025


On Wed, 18 Jun 2025 20:58:20 GMT, Pabulaner IV <duke at openjdk.org> wrote:

> This pull request fixes the system menu bar on Mac when combining windows of Swing and JavaFX.
> 
> The first issue was to get the native menu bar working simultaneously on Swing and JavaFX, which was done by just returning always true inside the supportsSystemMenu method.
> 
> The second issue was to remove all system menu items installed by a swing window. This was fixed by checking the system menu bar every time an item is inserted or removed and removing all menu items that are not owned by JavaFX. This check is done on every insert and remove as JavaFX does not have a clear method inside the MenuBarDelegate class that could be called every time the window gets the focus.
> 
> I tested the fix with two Swing and two JavaFX windows that are run inside the same application and it works without any errors.
> 
> Co-Author: @FlorianKirmaier

But how should it decide this?

Because if You have for example a Swing window and a JavaFX window both should be able to set the native menu bar on MacOS when they gain focus. At least this would make the application look consistent. 

Although it is discouraged to use AWT / Swing and JavaFX together, in some cases it can't be avoided due to the need to use some AWT or Swing functionality alongside with JavaFX. 

So I would be really grateful if You would have some suggestions or point me in the right direction what would be an acceptable approach to fix this issue.

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

PR Comment: https://git.openjdk.org/jfx/pull/1835#issuecomment-2997900326


More information about the openjfx-dev mailing list