import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class maja extends Applet implements ActionListener{ TextField tf=new TextField("2"); public maja(){ add(tf); tf.addActionListener(this); } public void paint(Graphics g){ int arv=Integer.parseInt(tf.getText().trim()); //loeb textboxist sisse int nr=1; int a=80;//ühe korruse kõrgus g.setColor(Color.blue); g.drawLine(150,20,40,100);//vasaku katuse joon g.drawLine(150,20,260,100);//parema katuse joon g.fillRect(40,100+arv*80,220,80); //uksekorruse ristkülik g.setColor(Color.red); //värvin ukse punaseks g.fillRect(130,120+arv*80,60,60);//uks g.setColor(Color.black); g.drawLine(135,150+arv*80,145,150+arv*80); while(nr<=arv){ g.setColor(Color.blue); g.fillRect(40,20+a,220,80); //x,y,laius, kõrgus //korrus g.setColor(Color.red); g.fillRect(70,40+a,30,30); g.fillRect(135,40+a,30,30); //aken vasak g.fillRect(200,40+a,30,30); //aken parem nr=nr+1; a=a+80; } } public void actionPerformed(ActionEvent e){ repaint(); } }