| Author |
Shortcut Keys
|
Barry Andrews
Ranch Hand
Joined: Sep 05, 2000
Posts: 523
|
|
Hi, Can anyone tell me what class to use to create shortcut keys? Example: If I have a button named "Go", and I want to create a shortcut with Alt G. How do I do this? Thanks in advance!!! Barry
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
Barry, If you are doing this in Swing it is built in... just do: In the code above it is actually the g key and not Alt-G that "presses" the button... but this is the easiest way to do it. If, on the other hand, you have your heart set on Alt-G, or you are using the AWT components, you will need to define a KeyListener for your components and test for an Alt-G combination. (Probably with a case statement that goes through all the keys you use and calls a method that is also called by the buttons ActionListener...) HTH, -Nate
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
Barry Andrews
Ranch Hand
Joined: Sep 05, 2000
Posts: 523
|
|
|
Thanks Nathan. I will try it!
|
 |
 |
|
|
subject: Shortcut Keys
|
|
|