wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes About Keybinding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "About Keybinding" Watch "About Keybinding" New topic
Author

About Keybinding

Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74

if i use "control alt 7" as key strokes this Code work properly but if use "control s" it dose not work .
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Have you tried using "control S"?


luck, db
There are no new questions, but there may be new answers.
Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74
Yes i tried but stil it dosent work
Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74

in my case i have two buttons called add_button and search_button.I used "control S" for search_button and "control A" for add_button. "control S" is working properly as you said but "control A "is not working
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2155
    
    7
Maybe another component is intercepting the KeyStroke.

For example text components use "Control A" to select the text of the component.

If you need more help then post your SSCCE demonstrating the problem.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Kasun Wixkramanayake wrote:

I always prefer the direct way, that doesn't require parsing:
Note that in this case the 'S' needs to be uppercase, or it will be an incorrect key code.

For those wondering, 'S' == KeyEvent.VK_S. I prefer the short version.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2155
    
    7
I like using the String so I don't have to create a separate key for the InputMap/ActionMap:

 
wood burning stoves
 
subject: About Keybinding
 
Similar Threads
tab press in JTable should go to the next rows text fieldhow?
getting KeyPressed for JDialog? example?
Using ActionMap for HotKey mapping
doing same job on two or more events
Bind jbutton event to a keystroke