tags:

views:

106

answers:

2

OK so my applet is not compiling and I Googled some answers and none worked. (Such as taking public out of public class)...

Here's my code: http://www.so.pastebin.com/MBjZGneg

Heere is my error:

C:\Users\Dan\Documents\DanJavaGen\Inventory.java:12: Inventory is not abstract and does not override abstract method keyReleased(java.awt.event.KeyEvent) in java.awt.event.KeyListener public class Inventory extends Applet implements KeyListener {

... help? :) please.

+2  A: 

It means what it says. You are not implementing the keyReleased method. You're also not implementing keyTyped. If you want to keep your current class structure, you can add empty methods:

public void keyReleased(KeyEvent e){} // ignore
public void keyTyped(KeyEvent e){} // ignore

If you put the listener in a separate (possibly inner) class, you could extend KeyAdapter, which provides these empty methods for you.

Matthew Flaschen
Well now I added keyRelased... and I get "Inventory is not abstract and does not override abstract method keyTyped(java.awt.event.KeyEvent) in java.awt.event.KeyListener"..Isn't there a way I can make it so it doesn't need all of them inside the code and have the ones I Just need?
Dan
Yes, you can use KeyAdapter. However, one class can not extend both KeyAdapter and Applet so you would need to add a new class.
Matthew Flaschen
OOoooooooh. OK. Got it, thank you Matthew.
Dan
A: 

It's obvious that you need to override the Method "KeyReleased" in your Inventory class. I can't locate such one in your class.

Simply add it to your class and add behavior

KroaX