Problem with Extended StackWindow containing a MenuBar on Apple Mac

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Extended StackWindow containing a MenuBar on Apple Mac

kacollins
I am writing a plugin which extends a StackWindow with some additional control buttons added above the imageCanvas. That is all working fine on Windows, Linux and Mac. I also add a menuBar (NOT JmenuBar) to the extended StackWindow, and that works fine for Windows and Linux. On the Mac (with OSX 10.5.8 and java 1.5.0_30 (32-bit)), almost everything works. When ImageJ is opened, its menuBar shows up in the Mac screenMenuBar (Mac's common menu bar) as expected, and when an image is opened (with a menuBar added to the extended StackWindow), its menuBar replaces the ImageJ menuBar as expected. After clicking on the ImageJ toolbar, its menuBar reappears in the screenMenuBar. All is fine so far.
    The problem occurs next. After opening an image, clicking the ImageJ toolbar, and then reclicking on the the extended StackWindow, the extended StackWindow menuBar never returns to the Mac screenMenuBar. I can not find any way to get it to display again.

    I have tried to work around the problem by using all of the following to keep the StackWindow's menuBar attached to the StackWindow frame and not to the screenMenuBar, but none of these combinations make that happen. The StackWindow's menuBar always goes to the screenMenuBar. I have placed this code in in several places including ImageJ.java, ImageWindow.java (custom IJ compile), and my extended StackWindow code. I am trying the variety of setProperty commands, becasue I am not sure what the proper one is for recent java builds.
System.setProperty("com.apple.macos.useScreenMenuBar", "false");
System.setProperty("apple.laf.useScreenMenuBar", "false");
System.setProperty("apple.awt.useScreenMenuBar", "false");

I have also tried modifying the info.plist file in the Mac distribution to set the following to both true and false. In each case, the above behavior persists. I have also tried the other two statements above in the info.plist file.
<key>com.apple.macos.useScreenMenuBar<\key>

Does anyone have any ideas on how to get either the extended StackWindow's menuBar to stay attached to the extended StackWindow, or to work properly in the screenMenuBar?

I have searched for answers for a couple of days now, with no luck. I am hoping someone will embarrass me with an easy fix (or even a hard one)!

Thanks,
     Karen
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Extended StackWindow containing a MenuBar on Apple Mac

kacollins
Could I provide more information about this question that might help someone to help me with some ideas to solve this issue?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Extended StackWindow containing a MenuBar on Apple Mac

kacollins
Problem Solved.

Part of the "windowActivated" method in ImageJ's ImageWindow class is:

         if (IJ.isMacintosh() && ij!=null && !quitting) {
             IJ.wait(10); // may be needed for Java 1.4 on OS X
             setMenuBar(Menus.getMenuBar());
         }

This code overwrites the plugin's menubar with the IJ menus on the Mac screenMenuBar,
so the plugin's menus never appear on the screenmenubar. This needs to happen since ImageWindow has no menubar and the screenmenubar would contain no menus after an image window is selected.

If you extend ImageWindow with code that provides a menubar, the windowActivated method will need to be overridden and modified to replace the Menus.getMenuBar() with your own menubar. Or, it seems with Mac Java 1.5.0_30 (32-bit), the menubars display properly without any Mac specific code at all, although you may want to follow the above example for maximum compatibility.

Karen