import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class HiireRuut extends Applet implements MouseListener{ int x=100; int y=60; int d=20; public HiireRuut(){ addMouseListener(this); } public void paint(Graphics g){ g.drawRect(x-d/2, y-d/2, d, d); } public void mousePressed(MouseEvent e){ x=e.getX(); y=e.getY(); repaint(); } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String argumendid[]){ Frame f=new Frame("Vajuta hiirega"); f.setSize(300, 300); f.add(new HiireRuut()); f.setVisible(true); } }