由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Java menu accelerator not working
相关主题
java and javascript 问题请教,有包子java rugular expression question
为啥画不出来?NullPointerException 问题
折腾了一天,实在是绝望了,请教请教新手请教一个问题
新手求助,急急急!!![转载] 这个是什么错误呀?
help "java.lang.NoSuchMethodError"JDK1.4 bug: Mnemonic key does not work in Windows Look and Feel?
No decent way for input password from command line.any JAXB high hands?
what is the problem?Re: 如何在两个窗口之间通信?
急问如何append double 数据到txt文件Re: [转载] create gif/png image in C or ja
相关话题的讨论汇总
话题: menu话题: java话题: working话题: jmenubar
进入Java版参与讨论
1 (共1页)
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)
: {

1 (共1页)
进入Java版参与讨论
相关主题
Re: [转载] create gif/png image in C or jahelp "java.lang.NoSuchMethodError"
JFrame怎么设定窗口为隐藏?No decent way for input password from command line.
JFrame怎么设定ontopwhat is the problem?
swing 在 mac intel 下的bug怎么修正?急问如何append double 数据到txt文件
java and javascript 问题请教,有包子java rugular expression question
为啥画不出来?NullPointerException 问题
折腾了一天,实在是绝望了,请教请教新手请教一个问题
新手求助,急急急!!![转载] 这个是什么错误呀?
相关话题的讨论汇总
话题: menu话题: java话题: working话题: jmenubar