import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class Klahvikuular2 extends Applet implements KeyListener{ int x=100, y=100; public Klahvikuular2(){ addKeyListener(this); } public void paint(Graphics g){ g.drawOval(x-10, y-10, 20, 20); } public void keyPressed(KeyEvent e){ int kood=e.getKeyCode(); if(kood==KeyEvent.VK_LEFT)x--; if(kood==KeyEvent.VK_RIGHT)x++; if(kood==KeyEvent.VK_UP)y--; if(kood==KeyEvent.VK_DOWN)y++; repaint(); } public void keyReleased(KeyEvent e){} public void keyTyped(KeyEvent e){} public static void main(String argumendid[]){ Frame f=new Frame("Klahvikuular"); f.add(new Klahvikuular2()); f.setSize(300, 300); f.setVisible(true); } }