import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Pliiats extends Applet implements ActionListener{ int nr=3; Button start=new Button(" K ä i v i t a ! "); public Pliiats(){ add(start); start.addActionListener(this); } public void actionPerformed(ActionEvent e){ Graphics g=getGraphics(); nr=1; if(e.getSource()==start){ int loendur=0; int a=125; int b=125; int c=200; int d=200; int dd=200; int f=500; int ff=200; int h=200; int i=200; int j=200; int k=500; int l=500; int m=500; int n=500; for(loendur = 0; loendur<149; loendur = loendur+1){ a=a+3*nr; b=b+3*nr; c=c+2*nr; d=d+2*nr; dd=dd+2*nr; f=f-2*nr; ff=ff+2*nr; h=h+2*nr; i=i+2*nr; j=j+2*nr; k=k-2*nr; l=l-2*nr; m=m-2*nr; n=n-2*nr; g.setColor(Color.blue); g.drawLine(a, 350, h, 300); g.drawLine(b, 350, i, 400); g.drawLine(c, 300, j, 400); g.drawLine(d, 300, k, 300); g.drawLine(dd, 400, l, 400); g.drawLine(f, 300, m, 400); g.drawLine(ff, 350, n, 350); try{Thread.sleep(20);}catch(Exception ex){} g.setColor(getBackground()); g.drawLine(a, 350, h, 300); g.drawLine(b, 350, i, 400); g.drawLine(c, 300, j, 400); g.drawLine(d, 300, k, 300); g.drawLine(dd, 400, l, 400); g.drawLine(f, 300, m, 400); g.drawLine(ff, 350, n, 350); } for(loendur = 0; loendur<149; loendur = loendur+1){ a=a-3*nr; b=b-3*nr; c=c-2*nr; d=d-2*nr; dd=dd-2*nr; f=f+2*nr; ff=ff-2*nr; h=h-2*nr; i=i-2*nr; j=j-2*nr; k=k+2*nr; l=l+2*nr; m=m+2*nr; n=n+2*nr; g.setColor(Color.blue); g.drawLine(a, 350, h, 300); g.drawLine(b, 350, i, 400); g.drawLine(c, 300, j, 400); g.drawLine(d, 300, k, 300); g.drawLine(dd, 400, l, 400); g.drawLine(f, 300, m, 400); g.drawLine(ff, 350, n, 350); try{Thread.sleep(20);}catch(Exception ex){} g.setColor(getBackground()); g.drawLine(a, 350, h, 300); g.drawLine(b, 350, i, 400); g.drawLine(c, 300, j, 400); g.drawLine(d, 300, k, 300); g.drawLine(dd, 400, l, 400); g.drawLine(f, 300, m, 400); g.drawLine(ff, 350, n, 350); } } } public static void main(String argumendid[]){ Frame f=new Frame("2D pliiats tegemas tiiru 2D ruumis "); f.add(new Pliiats()); f.setSize(700, 750); f.setVisible(true); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); } }