On Thu, 3 Jul 2025 07:04:24 GMT, Florian Kirmaier <[email protected]> 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 worked without any errors, but on further >> testing I noticed some issues with the menu bar. I am currently writing the >> test and fixes for it. >> >> Co-Author: @FlorianKirmaier > > The model we are trying to have here is quite simple. > > **Background** > When a Window/Toolkit gets focused, it defines which menus should be shown. > This is done by removing the old menus, and adding their own. > This is basically, what the OS does, when you switch from Application A to B, > just inside one process. > > Actually, we only wanted to make the JavaFX menu work when Swing/AWT was > started first. > But as far as we see, our solution also makes all combinations work. > > **Test** > What is definitely missing, which we will add, are unit tests. > We have already investigated - there is an Apple Command line API, which > allows us to read out which menus are currently shown. We will add some > unit-tests, which should provide confidence that this is working reliably. > > I hope these tests will improve the confidence, that this solution is correct > and maintainable. I decided to close this PR and to open a new one after discussing it with @FlorianKirmaier as we both think this will simplify things. This PR contains a lot of comments on the first version of the fix and since it was entirely rewritten makes it unnecessarily complex. ------------- PR Comment: https://git.openjdk.org/jfx/pull/1835#issuecomment-3288363299
