KeyListener error -
i have problem adding keylistener aplication:
app.game
not abstract , not override abstract methodkeyrelased(java.awt.event.keyevent)
in java.awt.event.keylistener
i try create new public class keyadapt
. gives same error.
code of application the:
public int x = 100, y = 100; public class game extends jframe implements keylistener { public game() { super(); setdefaultcloseoperation(jframe.dispose_on_close); setlocationrelativeto(null); setundecorated(true); setlayout(null); setvisible(true); } public void paint (graphics gdc) { gdc.clearrect(0, 0, getsize().width, getsize().height); getgraphics().drawoval(x, y, 20, 20); } public void keypressed(keyevent e) { if (e.getkeycode() == keyevent.vk_up ) { y++; } if (e.getkeycode() == keyevent.vk_down ) { y--; } if (e.getkeycode() == keyevent.vk_right ) { x++; } if (e.getkeycode() == keyevent.vk_left ) { x--; } } public void keyrelased(keyevent e) { if (e.getkeycode() == keyevent.vk_up ) { y+=0; } if (e.getkeycode() == keyevent.vk_down ) { y-=0; } if (e.getkeycode() == keyevent.vk_right ) { x+=0; } if (e.getkeycode() == keyevent.vk_left ) { x-=0; } } public void keytyped(keyevent e) {} }