user1233664
user1233664

Reputation:

Hot Keys missaligned in Swing

I'm using Swing to create a hot key for all the menus. For Save As menu item The 'A' should be under lined instead of 'a' immediately following the S in Save as. I've used the following code to create hot keys for menuitems "for Save As Menu: MenuItem.setMnemonic('a');"

Upvotes: 1

Views: 66

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285405

You'll want to use the setDisplayedMnemonicIndex(...) to provide a hint to the JVM for which letter should get the underline. You invoke this after calling setMnemonic(KeyEvent.VK_A)

Please check out the API for more on this: AbstractButton API

Upvotes: 4

Related Questions