命令+;mac osx中java 1.7的equals热键被多次调用
在osx上使用java-7时,如果我将热键Command+设置为一个菜单项,则在触发它时会多次调用它 我编写了一个简单的应用程序来演示这种行为。热键只是在控制台中打印出系统时间命令+;mac osx中java 1.7的equals热键被多次调用,java,macos,swing,java-7,hotkeys,Java,Macos,Swing,Java 7,Hotkeys,在osx上使用java-7时,如果我将热键Command+设置为一个菜单项,则在触发它时会多次调用它 我编写了一个简单的应用程序来演示这种行为。热键只是在控制台中打印出系统时间 import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; public class n
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
public class newWindow {
static JFrame newWindow;
public static void main(String args[]) {
new newWindow().createWindow();
}
public static void createWindow() {
newWindow = new JFrame("Window1");
//Where the GUI is created:
JMenuBar menuBar;
JMenu menu;
JMenuItem menuItem;
//Create the menu bar.
menuBar = new JMenuBar();
newWindow.setJMenuBar(menuBar);
newWindow.setVisible(true);
//Build the first menu.
menu = new JMenu("A Menu");
menuBar.add(menu);
//a group of JMenuItems
menuItem = new JMenuItem("A text-only menu item");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
System.out.println(System.currentTimeMillis());
}
});
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
menu.add(menuItem);
}
}
如果你们遇到同样的问题,请随时尝试代码并告诉我。我也有同样的问题。但是,Java 1.8中的行为似乎已经修复,因此它似乎已经修复。我也有同样的问题。但是,在Java1.8中,该行为似乎是固定的,因此它似乎已经被固定