• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is wrong with this code?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try keyPressed with a small k
public void KeyPressed(KeyEvent event) to
public void keyPressed(KeyEvent event)
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic