Reputation: 27
In Visual Studio as you use the '&
' before a letter in the text of a button or etc. for getting a letter underlined shortcut so ALT + that letter executes the button or etc.
I wanna know how do that in Java. I know it's possible because I have seen underlined letter shortcuts pop up in JOptionPanes
.
I have tried putting the &
symbol in JButton
Text but doesn't work.
Please Help!
Upvotes: 2
Views: 576
Reputation: 4473
You have to pragrammatically set this shortcut for each button. For example:
enterButton = new JButton("Enter");
enterButton.setMnemonic(KeyEvent.VK_ENTER); // Shortcut: Alt + Enter
Upvotes: 1