• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding KeyStroke to JCheckBox

 
Lubomir Kolacik
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add KeyStrokes to group of CheckBoxes ,so when user hits 1 on keyboard,then first JCheckBox. will be selected / deselected .

I have made this part of code ,but its not working, can somebody point me into correct direction? ( I can also put action creating outside the loop , nothing change )

 
Rob Spoor
Sheriff
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Casting an int to a char doesn't turn it into the matching char. For instance, (char) 9 is not the character '9' but a tab character instead; see http://www.asciitable.com/.
To convert an int into the matching char, use Character.forDigit.
 
Lubomir Kolacik
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Casting an int to a char doesn't turn it into the matching char. For instance, (char) 9 is not the character '9' but a tab character instead; see http://www.asciitable.com/.
To convert an int into the matching char, use Character.forDigit.


Thanks, its true ,so I remade it into : (char)('0'+i) , but its still not working.

I was thinking about focus , but if there use WHEN_IN_FOCUSED_WINDOW it should not matter then?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try removing the 'true'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic