• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Adding KeyStroke to JCheckBox

 
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 )

 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try removing the 'true'
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!