c*****t 发帖数: 1879 | 1 How to get java menu accelerator working? The menu shows
up the correct key sequence, but the accelerator is not
working. Here is a sample code that demonstrates the problem.
Any help would be greatly appreciated. Thanks
import java.awt.event.*;
import javax.swing.*;
public class Menu
{
public static void main (String[] args)
{
JFrame frame = new JFrame ();
JMenuBar menuBar = new JMenuBar ();
JMenu menu;
JMenuItem item;
menu = new JMenu ("File");
item = new JMenuItem ("Test");
item.addActionL | c*****t 发帖数: 1879 | 2 If I change the the line to
item.setAccelerator (KeyStroke.getKeyStroke (KeyEvent.VK_C, InputEvent.CTRL_MASK));
then the code works.
However, since I need to load keyboard accelerator from script, it would
be nice to be able to use KeyStroke's own key parsing ability to do the
job. Any one could help?
Thanks.
【在 c*****t 的大作中提到】 : How to get java menu accelerator working? The menu shows : up the correct key sequence, but the accelerator is not : working. Here is a sample code that demonstrates the problem. : Any help would be greatly appreciated. Thanks : import java.awt.event.*; : import javax.swing.*; : public class Menu : { : public static void main (String[] args) : {
|
|