简体   繁体   中英

Mac OS X Java menu bar disappears

I'm running a Java application on Max OS X 10.7.5 and using Java 7. My application has its own menu bar. When I click one menu item it will bring a dialog. Problem is when I invoke the dialog, whole menu bar disappears and after I close the dialog menu bar appears. This problem is not seen on Java 6 and only on Java 7.

Any suggestions?

The menu bar you see corresponds to the current active window. Since you dialog does not have a menu bar of its own, none will show when it is the active window. Then when your dialog closes and your application window becomes active, its menu bar will again be displayed.

One solution is to use setDefaultMenuBar() . See this example:

Application app = Application.getApplication();
app.setDefaultMenuBar(myJMenuBar);

Unfortunately, this is not currently implemented in Java 7. So you may be out of luck. Here is the bug report for this feature: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267

Here is an example of someone doing the same thing, and a cutout of the response given from code ranch

"In mac normally we don't want to set any look and feel.because mac takes the menubar for it's own.so you don't set any look and feel in the code for mac implementation.just gave it as without any look and feel code...then i will hope now it will works fine.because the same issue i had faced in mac with swing application...."

--ashok---

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM