import java.util.*; import java.io.*; import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class sitik extends Applet implements ActionListener, Runnable { TextField tf=new TextField("0.10"); double nurk=100; double raadius=60; double samm=0.01; int paus=10; boolean veel=true; public sitik(){ add(tf); tf.addActionListener(this); new Thread(this).start(); } public void joonista(){ Graphics g=this.getGraphics(); if(g!=null){ g.setColor(Color.lightGray); g.fillRect(0, 0, getSize().width, getSize().height); String kontroll=tf.getText().trim(); if(kontroll.length()==0){ kontroll="0"; tf.setText("0"); g.setColor(Color.black); } double arv=Double.parseDouble(tf.getText().trim()); samm=arv; g.setColor(Color.red); g.fillOval(105, 300+(int)((raadius)*Math.cos(nurk))+5, 30, 30); //pea g.setColor(Color.black); g.drawOval(105, 300+(int)((raadius)*Math.cos(nurk))+5, 30, 30);//pea ring g.fillOval(113, 307+(int)((raadius)*Math.cos(nurk))+5, 5, 5);//silm1 g.fillOval(122, 307+(int)((raadius)*Math.cos(nurk))+5, 5, 5);//silm2 g.drawLine(150, 350, 135, 331+(int)(raadius*Math.cos(nurk))-15); //parem reis g.drawLine(90, 350, 105, 331+(int)(raadius*Math.cos(nurk))-15); //vasak reis g.drawLine(125, 340+(int)(raadius*Math.cos(nurk))-15, 115, 340+(int)(raadius*Math.cos(nurk))-15); //suu g.drawLine(90, 350, 85, 380); //vasak säär g.drawLine(150, 350, 155, 380); // parem säär nurk=nurk+samm; } } public void run(){ String kontroll=tf.getText().trim(); while(veel){ try{ joonista(); Thread.sleep(paus); } 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 sitik()); f.setSize(260, 500); f.setVisible(true); } }