I wish I could word this question better. Partly I just don't know the name of what I'm looking for.
With Visual Studi开发者_如何学JAVAo and Windows forms you can add an ampersand to create a "shortcut" key to a button by pressing Alt + [That Letter]. Like My &Button
... Alt + B would be the shortcut.
Is there an equivalent of this in Java SWING? I am using NetBeans IDE 6.9.1.
Thank you all!
That's called a mnemonic.
Use setMnemonic
(javadoc)
See http://download.oracle.com/javase/tutorial/uiswing/components/menu.html#mnemonic
You use JMenutItem.setMnemonic()
; I don't think there's a handy-dandy shortcut like the ampersand.
精彩评论