Hey there! I have a JButton and called setMnemonic(KeyEvent.VK_ENTER); on it. But the button won't be invoked when I press the enter-key. When I set the mnemonic shortcut to 'b' or something else, it doesn't work either. The JButton is inside of a JPanel which is inside of a JDialog. Thanks for help Florian Meyer
Does the text on your button actually have a 'b' in it? Setting the mnemonic to enter won't work, as you should rather register a keyboard action if this is the key you wish to use, or look at setDefaultCapable() on JButton (Key stroke would then depend on your current look and feel). If you wish to use mnemonics the char you set as the mnemonic should be contained in the text of you button for it to work properly (and for it to make sense to the user).
I want my playground back. Here, I'll give you this tiny ad for it:
Programmatically Create PDF Using Free Spire.PDF with Java