import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import java.awt.image.*; public class Hiir extends JComponent implements MouseMotionListener{ Vector v=new Vector(); BufferedImage puhver=new BufferedImage(600,600,BufferedImage.TYPE_INT_RGB); public Hiir(){ //addMouseListener(this); addMouseMotionListener(this); Graphics g=this.getGraphics(); } public static void main(String[] args){ JFrame f=new JFrame("KODUTÖÖ"); f.getContentPane().add(new Hiir()); f.setSize(600,600); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } public void mousePressed(MouseEvent e){} public void mouseMoved(MouseEvent e){ v.add(new Koht(e.getX(),e.getY())); if (v.size()>2){ Koht k=(Koht)(v.remove(0)); k.start(); } System.out.println(v.size()); } public void mouseDragged(MouseEvent e){} public void joonistan(int x, int y){ Graphics graafika=this.getGraphics(); Graphics g=puhver.getGraphics(); g.setColor(Color.white); g.fillRect(0,0,getSize().width, getSize().height); g.setColor(Color.black); for(int i=0;i<20;i++){ int xr, yr; if(x>500){ g.setColor(Color.green); xr=i*2; yr=i*3; } else if(x>300){ g.setColor(Color.red); xr=(int)(10*Math.cos(i)); yr=(int)(10*Math.cos(i)); } else{ g.setColor(Color.black); xr=(int)(20*Math.sin(i/3)); yr=(int)(20*Math.cos(i/3)); } g.drawOval(x+xr,y+yr,5,5); try{Thread.sleep(100);}catch(Exception e){} } g.setColor(Color.white); graafika.drawImage(puhver,0,0,this); } class Koht extends Thread{ public int x, y; public Koht(int x, int y){ this.x=x;this.y=y; } public void run(){ joonistan(x, y); } } }