If I opt to use Swing Actions, rather than JMenuItems, in my JMenus, can I still use mnemonics (e.g., Alt-F-N to trigger the "New" item in the "File" menu)? JMenuItems have a setMnemonic() method; AbstractActions do not. Is there a way to do this, or is this just a limitation of Swing Actions? Thanks in advance. D.
Sorry, I should've mentioned that I'm using JDK 1.2.2. I know that with 1.3, I should not add Actions directly to my JMenu but instead create a JMenuItem; use its setAction() method to configure it; then add it to the JMenu. But there is no setAction() method prior to 1.3 so I cannot use that approach. Any ideas. D.
When you use actions, a JMenuItem object is still added to the menu. If you look at the sig for add you'll see that it returns a JMenuItem: public JMenuItem add(Action a); You simply need to set the mneumonic on the returned menuitem: JMenuItem item = menu.add(action); item.setMnemonic(...
Post by:autobot
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards