import java.applet.Applet; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Isetoo extends Applet implements MouseMotionListener, MouseListener { private PThread thread = null; private int x = 0; private int y = 0; private int mx = 0; private int my = 0; private int md = 0; private boolean doPaint = false; public Isetoo() { addMouseMotionListener(this); addMouseListener(this); thread = new PThread(this); thread.start(); } public void paint(Graphics g) { if(doPaint) { mx = (int) (Math.random() * 10); my = (int) (Math.random() * 10); md = (int) (Math.random() * 20); if((Math.random()*100)>50) { mx=mx-mx*2; } if((Math.random()*100)<50) { my=my-my*2; } g.setColor(new Color((int) (Math.random() * 255), (int) (Math.random() * 255), (int) (Math.random() * 255))); g.drawOval(x + mx, y + my, md, md); } } class PThread extends Thread { Isetoo parent = null; public PThread(Isetoo par) { parent = par; } public void run() { while (true) { parent.repaint(); try { Thread.sleep(100);} catch (Exception e) {} } } } public void mouseDragged(MouseEvent e){} public void mouseMoved(MouseEvent e) { x = e.getX(); y = e.getY(); } public void mouseClicked(MouseEvent e){} public void mousePressed(MouseEvent e){} public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){ doPaint = true; } public void mouseExited(MouseEvent e){ doPaint = false; } public static void main(String[] argumendid) { JFrame f = new JFrame(); f.getContentPane().add(new Isetoo()); f.setSize(300, 300); f.setVisible(true); } }