• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is wrong with this code?

 
Emnaki Chih
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The KeyListener doesn't seem to work in my code, what is wrong with it? I know how others do it from searching other posts so tell me instead what I did wrong. thanx.

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try keyPressed with a small k
public void KeyPressed(KeyEvent event) to
public void keyPressed(KeyEvent event)
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Emnaki -

I'm surprised your compiler didn't complain about the method not being found. Typographical errors are probably the most common ones programmers make. If a piece of code doesn't work as expected, or fails to compile, the first thing I do is carefully check my spelling and capitalization...
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I guess this one highlights the problem with extending an adapter class. Any slight miss-spelling will mean that you are NOT overriding the desired method - the method you wrote is not doing anything and all the key stuff is going into the empty methods. The "mplements" clause does not help because of the empty implementing code in the extended adapter!

Ed
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eddie, this only prooves the problem a newbie may encounter while not reading the API. That's all. Inheritance is essential to OOP. Polymorphism too. If you pay no attention to your code this doesn't proove the inheritance is wrong, but rather that your coding is bad .

--
./pope
[the_mindstorm]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!