import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class jukud extends Applet implements MouseListener{ public jukud(){ addMouseListener(this); } public void mousePressed(MouseEvent e){ int x=e.getX(); int y=e.getY(); new katseTeine (x, y, getGraphics()).start(); } public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseClicked(MouseEvent e){} static void joonistakriipsud(Graphics g, int x, int y){ g.drawOval(x,y,20,20); g.drawLine(x+10,y+20,x+10,y+50);//keha g.drawLine(x-5,y+65,x+10,y+50);//vasak jalg g.drawLine(x+10,y+50,x+25,y+65);//parem jalg g.drawLine(x-5,y+40,x+10,y+25);//vasak käsi g.drawLine(x+10,y+25,x+25,y+40);//parem käsi } public static void main(String argumendid[]){ Frame f=new Frame(); f.add(new jukud()); f.setSize(300, 300); f.setVisible(true); } } class katseTeine extends Thread{ int x, y; Graphics g; public katseTeine(int ax, int ay, Graphics ag){ x=ax; y=ay; g=ag; } public void run(){ double samm=1; //reaalarv for(;x<300; x=(int)(x+samm), samm=samm+5){ g.setColor(Color.red); jukud.joonistakriipsud(g,x, y); try{ Thread.sleep(300); }catch(Exception ex){} g.setColor(Color.green); jukud.joonistakriipsud(g,x, y); try{ Thread.sleep(300); }catch(Exception ex){} g.setColor(Color.white); jukud.joonistakriipsud(g,x, y); } } }