import java.awt.*; import java.awt.event.*; import java.applet.Applet; import java.lang.*; public class Haamer extends Applet implements ActionListener, Runnable{ int n=100; //vaia sügavus maapinnas// int nr=5; int nr2=60; int nr3=100; int m=60; //haamri kõrgus// TextField tf=new TextField("5"); //vaia jämedus// TextField tf2=new TextField("60"); //vaia pikkus// TextField tf3=new TextField("100"); //soovitud sügavus// Button nupp=new Button(" LÖÖ "); Button nupp2=new Button(" OK "); Button nupp3=new Button(" ALGUS "); public Haamer(){ add(nupp); add(nupp2); add(nupp3); add(tf); add(tf2); add(tf3); nupp.addActionListener(this); nupp2.addActionListener(this); nupp3.addActionListener(this); } public void paint(Graphics g){ g.setColor(Color.black); g.drawRect(50, n, nr, nr2); //vai// g.drawRect(40, m, 25, 30); //haamer// g.drawRect(37, 40, 3, 120); //vasak post// g.drawRect(65, 40, 3, 120); //parem post// g.drawLine(30, 160, 80, 160); //alumine joon// } public void run(){ int a=0; int b=1; if(n<=nr3){ while(a130){ n-=10; } n+=20; a+=2; } else { n+=10; a+=2; } } repaint(); } while(m+30>90){ m=m-10; } repaint(); } else { repaint();} } public void actionPerformed(ActionEvent e) { try { if(e.getSource()==nupp){ new Thread(this).start(); repaint(); } if(e.getSource()==nupp2){ nr=Integer.parseInt(tf.getText()); nr2=Integer.parseInt(tf2.getText()); nr3=Integer.parseInt(tf3.getText()); repaint(); } if(e.getSource()==nupp3){ n=100; nr=5; nr2=60; nr3=100; m=60; repaint(); } } catch(NumberFormatException ex) {} } public static void main(String argumendid[])throws Exception{ Frame f=new Frame("Joonistus"); f.add(new Haamer()); f.setSize(400, 400); f.setVisible(true); } }