Joe
Joe

Reputation: 385

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?

Upvotes: 0

Views: 1293

Answers (2)

martinez314
martinez314

Reputation: 12332

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: https://bugs.java.com/bugdatabase/view_bug?bug_id=8007267

Upvotes: 2

user2277872
user2277872

Reputation: 2973

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---

Upvotes: 0

Related Questions