setAccelerator « Menu « Java Swing Q&A





1. Java JMenu setAccelerator() problem    stackoverflow.com

When I set setAccelerator() to Control + A or Control + P and I run the program it doesn't detect the keystroke. Here's the code:

  menuItem = new JMenuItem("About");
  menuItem.setActionCommand("About");
 ...

2. setAccelerator in Java 6 wont work with invisible JMenuItem    coderanch.com

Had the same problem, and the fixes suggested above don't work. It's only the item that's invisible, not the entire menu (I want to keep some commands known only to the administrator of a program). This worked fine in 5, and with no code change fails to work in 6. Any ideas?