import java.awt.*; import java.applet.*; import java.awt.event.*; public class Liikumine2 extends Applet implements ActionListener{ TextField tf=new TextField(10); public Liikumine2(){ add(tf); tf.addActionListener(this); } public void actionPerformed(ActionEvent e){ try{ //veapüünis double x=10; double y=100; double aeg=0; double k=0; int alusY=200; double kiirus=40; // m/s, 1 ekraanipunkt vastab ühele meetrile double nurk=Math.toRadians( Double.parseDouble(tf.getText())); double siinus=Math.sin(nurk); double kosiinus=Math.cos(nurk); Graphics g=getGraphics(); while(aeg<10){ k=aeg*kiirus; x=k*kosiinus; y=k*siinus-9.8*aeg*aeg/2; g.setColor(Color.black); g.drawOval((int)x, alusY-(int)y, 10, 10); Thread.sleep(100); //ooteaeg millisekundites aeg=aeg+0.1; g.setColor(Color.white); g.drawOval((int)x, alusY-(int)y, 10, 10); } } catch (Exception probleem){ System.out.println(probleem); } } public static void main(String[] argumendid){ Frame f=new Frame(); f.add(new Liikumine2()); f.setSize(300, 300); f.setVisible(true); } }