• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Keybinding

 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 5133
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using "control S"?
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i tried but stil it dosent work
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 2600
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Camick
Ranch Hand
Posts: 2600
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like using the String so I don't have to create a separate key for the InputMap/ActionMap:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic