import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Lill extends Applet implements ActionListener{ TextField tf=new TextField("1"); public Lill(){ add(tf); tf.addActionListener(this);//textboxi värk } public void paint(Graphics g){ int arv=Integer.parseInt(tf.getText().trim()); int nr=1; int a=50;//ühe varre pikkus g.setColor(Color.blue); g.fillOval(150,150,40,40);//alumine õieleht g.fillOval(150,100,40,40);//ülemine lilleõis g.fillOval(120,125,40,40);//vasak g.fillOval(180,125,40,40);//parem g.setColor(Color.yellow); g.fillOval(150,130,40,30);//lille südamik g.setColor(Color.green); g.fillRect(166,190+arv*50,8,50);//vars g.drawLine(130,200+arv*50,166,240+arv*50);//muru g.drawLine(210,200+arv*50,174,240+arv*50); g.drawLine(185,210+arv*50,173,240+arv*50); while(nr<=arv){ g.setColor(Color.green); g.fillRect(166,140+a,8,50); nr=nr+1; a=a+50; } } public void actionPerformed(ActionEvent e){ repaint(); } public static void main(String argumendid[]){ // käivitab proge Frame f=new Frame("Exami lill"); f.add(new Lill()); f.setSize(350,450); f.setVisible(true); } }