import java.awt.*; import java.awt.event.*; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.Color; import java.applet.Applet; public class Juku extends Applet implements ActionListener, Runnable{ TextField tf=new TextField("0.01"); int oota=10; double nurk=10; double raadius=30; double samm=0.01; boolean veel=true; public Juku(){ add(tf); tf.addActionListener(this); new Thread(this).start(); } public void joonista(){ Graphics g=this.getGraphics(); if(g!=null){ g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); //String kontroll=tf.getText().trim(); //if(kontroll!=null){ //kontroll="0"; // } double arv=Double.parseDouble(tf.getText().trim()); samm=arv; g.setColor(Color.blue); g.fillOval(215, 250+(int)((raadius)*Math.cos(nurk))+5, 30, 30); //pea g.drawLine(230, 280+(int)((raadius)*Math.cos(nurk))+5, 230, 335+(int)((raadius)*Math.cos(nurk))+5); //kehakriips g.drawLine(250, 310+(int)((raadius)*Math.cos(nurk))+5, 230, 290+(int)((raadius)*Math.cos(nurk))+5); //parem käsi g.drawLine(210, 310+(int)((raadius)*Math.cos(nurk))+5, 230, 290+(int)((raadius)*Math.cos(nurk))+5); //vasak käsi g.drawLine(250, 350, 230, 350+(int)(raadius*Math.cos(nurk))-9); //liikuv parempoolne jalg g.drawLine(210, 350, 230, 350+(int)(raadius*Math.cos(nurk))-9); //liikuv vasakpoolne jalg g.drawLine(210, 350, 205, 380); //vasak säär, need ei liigu g.drawLine(250, 350, 255, 380); // parem säär g.drawLine(265, 380, 255, 380); //parem jalalaba g.drawLine(205, 380, 195, 380); //vasak jalalaba nurk=nurk+samm; } } public void run(){ while(veel){ joonista(); try{ Thread.sleep(oota); } catch(Exception e){e.printStackTrace();} } } public void actionPerformed (ActionEvent e){ if(e.getSource()==tf)joonista(); } public static void main(String argumendid[]){ Frame f=new Frame(); f.add(new Juku()); f.setSize(600, 600); f.setVisible(true); } }