warhammerdude20
05-15-2004, 02:19 AM
so i am making a game, and i cant get the keylistener to work. all i have found were examples of using keylisteners for textareas and stuff. i want to add a keylistener on to the applet itself, how do i do this... this is what i have tryed...
import java.awt.*;
import java.applet.Applet;
public class Game extends Applet implements Runnable,KeyListener{
addKeyListener(this);
//run init and all that jazz
public void keyPressed(KeyEvent e){System.out.println(e.getKeyCode());}
public void keyReleased(KeyEvent e){System.out.println(e.getKeyCode());}
}
i could always just go like
public boolean keyDown(Event e,int Key){}
but its decrapitated or something like that...
so if anyone knows what im doing wrong, please help me fix it.
thanks...
import java.awt.*;
import java.applet.Applet;
public class Game extends Applet implements Runnable,KeyListener{
addKeyListener(this);
//run init and all that jazz
public void keyPressed(KeyEvent e){System.out.println(e.getKeyCode());}
public void keyReleased(KeyEvent e){System.out.println(e.getKeyCode());}
}
i could always just go like
public boolean keyDown(Event e,int Key){}
but its decrapitated or something like that...
so if anyone knows what im doing wrong, please help me fix it.
thanks...