Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

KeyListener  RSS feed

 
Parth Sagdeo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I just cant figure out why nothing moves. Here's the code:
Im probably missing something really obvious, but even if i type an arrow, nothing happens.
Hope you can hel,
Parth
 
David Vickers
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Not much help here, but it all looks identical to a movement process i have in an graphic app. Mine has same listener, same event check etc, and repaint. Have you tried the obvious debug, with System.out.println("moved left").... at each key press?
If they are being reached, thats one less step to worry over?
 
Parth Sagdeo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For some reason, the keypressed ,etc. methodss arent't even getting executed, but I have no clue why.
 
Parth Sagdeo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
turns out keyListener requires focus, thanks eeryone anyway
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!