Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Keylistener help!

Posted on 2003-10-22
6
Medium Priority
?
264 Views
Last Modified: 2008-02-01
hi,
I am tring to add a key listener to my java 3D class by using this code

[code] public class SpinnerGame extends Applet implements KeyListener{  [/code]

But when i try to compile it says

[b] SpinnerGame is not abstract and does not override abstract method keyTyped(java.awt.event.KeyEvent) in java.awt.event.KeyListener [/b]

what does this mean??? it is so fustrating please can someone help
0
Comment
Question by:jamesloi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 128 total points
ID: 9601036
SpinnerGame has to implement these three public methods:

void keyPressed(KeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(KeyEvent e)
          Invoked when a key has been released.
 void keyTyped(KeyEvent e)
          Invoked when a key has been typed.
0
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 124 total points
ID: 9601169
Or you could create an inner class that extends KeyAdapter.

KeyAdapter is a convenience class that has "default" implementations of the key... methods.
0
 

Assisted Solution

by:zechariahs
zechariahs earned 124 total points
ID: 9621348
CEHJ is right, but I just want to give you some more detail.

keyPressed is invoked when a key is pressed down.
keyReleased is invoked when a pressed key is let up.
keyTyped is invoked after a key has been pressed and released.

Only reason I went into more detail is because I've seen a lot of people rack their brains over the differences.
0
 
LVL 3

Assisted Solution

by:InNoCenT_Ch1ld
InNoCenT_Ch1ld earned 124 total points
ID: 9720504
0
 
LVL 92

Expert Comment

by:objects
ID: 10194174
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between CEHJ, jimmack, zechariahs and InNoCenT_Ch1ld

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

objects
EE Cleanup Volunteer
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question