Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Keylistener help!

Posted on 2003-10-22
6
Medium Priority
?
266 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

886 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