Solved

Keylistener help!

Posted on 2003-10-22
6
251 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
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 32 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 31 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 31 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 31 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
arguments to jar 5 39
runtime exception 2 50
hashmap order 17 40
jmeter usage 4 33
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

735 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