Redian新闻
>
Java menu accelerator not working
avatar
Java menu accelerator not working# Java - 爪哇娇娃
c*t
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
avatar
c*t
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)
: {

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。