My code:
fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
fileMenu.setDisplayedMnemonicIndex(0);
Javadocs for AbstractButton.setDisplayedMnemonicIndex()
say that
Not all look and feels may support this.
I set my look and feel to UIManager.getSystemLookAndFeelClassName()
And I don't see underline on mnemonic even when the index is explicitely set by setDisplayedMnemonicIndex()
- under Windows 7 (only when I press ALT
).
It works however if I do not set the look & feel and leave just default java theme.
Is there a way to achieve this? Is it caused by the settings of Windows ?
You can change the behaviour that the underline only appears when pressing the Alt key by setting a property with the
UIManager
I think you need to do this before you display your first Swing component, but I'm not sure.