Swing菜单Java 7 mac osx [英] Swing menus Java 7 mac osx
问题描述
我一直在mac os x上测试我的Swing应用程序,它运行在applet上。
I've been testing my Swing application on mac os x which runs on an applet.
当我在浏览器中运行这个applet时,我注意到了鼠标 - 在JMenus / JMenuItems上无法正常工作。
When I run this applet in the browser, I noticed that the mouse-over on the JMenus/JMenuItems do not work correctly.
这是一个重现问题的小程序:
Here is a small program to reproduce the problem:
package com.macosx.tests;
import java.applet.Applet;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Example extends JApplet {
JMenuBar bar;
JMenu file, edit;
JMenuItem new1, save, close;
private void doStart() {
bar = new JMenuBar();
file = new JMenu("File");
edit = new JMenu("Edit");
new1 = new JMenuItem("New");
save = new JMenuItem("Save");
close = new JMenuItem("Close");
setJMenuBar(bar);
bar.add(file);
bar.add(edit);
file.add(new1);
file.add(save);
file.add(close);
}
@Override
public void start() {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
doStart();
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
使用此代码生成.jar文件。在Eclipse中,您可以使用导出功能,并且只确保将Main-Class定义为上面的类。
With this code, generate a .jar file. In Eclipse you can use the Export functionality and only make sure you define the Main-Class as the class above.
一旦运行了jar,就创建一个html包含以下内容的文件:
Once you have the jar up an running, create an html file with the content:
<html>
<head>
<title>Menu test Applet</title>
</head>
<body>
<applet id="appletID" height="800" width="600"
code="com.macosx.tests.Example"
archive="tests.jar">
</applet>
</div>
</body>
</html>
在此之后,运行html文件并检查菜单:它们不应该接收鼠标悬停事件。
我做错了什么?这是一个Java错误吗?
有没有Mac用户来测试这个问题?
After this, run the html file and check the menus: they should not receive mouse-over events. Am I doing something wrong? Is this a Java bug? Any mac user out there to test this problem?
我正在使用最新的Oracle JRE for Mac运行Mac OSX 10.7.4(http:// www .oracle.com / technetwork / JAVA / JavaSE的/下载/ jre7的下载-1637588.html)。使用Firefox来测试它。
I'm running Mac OSX 10.7.4 with latest Oracle JRE for mac (http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1637588.html). Used Firefox to test this.
java.vendor Oracle Corporation
java.version 1.7.0_06
os.name Mac OS X
os.version 10.7.4
谢谢
推荐答案
这里的代码运行正常。我怀疑这是JRE中的一个错误。
The code works fine here. I suspect it is a bug in that JRE.
将代码更改为:
- 转储
java .version
&java.vendor
- 删除主要内容(这只会让事情混乱) - 然后..
- 提出错误报告。
- Dump
java.version
&java.vendor
- Remove the main (which just confuses things) - then..
- Raise a bug report.
试验机的详细信息
获得的详细信息来自属性小程序:
Name Value
java.vendor Oracle Corporation
java.version 1.7.0_05
os.name Windows 7
os.version 6.1
浏览器: FireFox 15.0
Browser: FireFox 15.0
这篇关于Swing菜单Java 7 mac osx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!