简体   繁体   English

Mac OS X Java菜单栏消失

[英]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. 我在Max OS X 10.7.5上运行Java应用程序并使用Java 7.我的应用程序有自己的菜单栏。 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. 在Java 6上看不到此问题,仅在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() . 一种解决方案是使用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. 不幸的是,目前还没有在Java 7中实现。所以你可能运气不好。 Here is the bug report for this feature: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267 以下是此功能的错误报告: http//bugs.sun.com/bugdatabase/view_bug.do?video_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...." “在mac中,我们通常不想设置任何外观和感觉。因为mac将菜单操作视为自己的。所以你没有在mac实现的代码中设置任何外观和感觉。只是没有任何外观和感觉代码...然后我希望它现在可以正常工作。因为我在mac中遇到了与摇摆应用相同的问题....“

--ashok--- --ashok ---

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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