import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class Liikuvkriips extends Applet implements KeyListener{ int x=250, y=250; public Liikuvkriips(){ init(); } public void init(){ addKeyListener(this); requestFocus(); } public void paint(Graphics g){ g.setColor(Color.blue); g.fillRect(x-2, y-10, 4, 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){} }