Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I can't get my KeyListener to work.  RSS feed

 
Joseph Alrawi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!

I wanted to try out using a KeyListener to read what key I press so it can paint a circle in my frame, but I can't get it to work, any suggestions?



Thanks for your help!
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Keyboard class isn't used for anything - if you want to use it as a KeyListener you have to allocate an instance and set it as key listener on whatever component should listen to those key strokes.

Apart from that, why does the class extend JPanel if you are not using as a JPanel? Its paint method will not be called.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!