import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class Puu extends Applet implements ActionListener{ TextField tf=new TextField("1"); public Puu(){ add(tf); tf.addActionListener(this); } public void paint(Graphics ekraan){ int arv=Integer.parseInt(tf.getText().trim()); int nr=1; int a=60; while(nr<=arv){ ekraan.setColor(Color.black);//joonistan puu ekraan.fillRect(50+a, 120, 30, 70); ekraan.setColor(Color.green); ekraan.fillOval(40+a, 60, 50, 70); nr=nr+1; a=a+60; } } public void actionPerformed(ActionEvent e){ repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("See on minu tehtud puu COPYRIGHT RST"); f.add(new Puu()); f.setSize(400, 400); f.setVisible(true); } }