Solved

Keylistener help!

Posted on 2003-10-22
6
245 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now