import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Ruut extends Applet implements ActionListener{ int nr=100; TextField tf=new TextField("100"); public Ruut(){ add(tf); tf.addActionListener(this); } public void actionPerformed(ActionEvent e){ nr=Integer.parseInt(tf.getText().trim()); repaint(); } public void paint(Graphics g){ g.drawRect(10, 50, nr, nr); } public static void main(String argumendid[]){ Frame f=new Frame("Ruudu joonistamine"); f.setSize(300, 300); f.add(new Ruut()); f.setVisible(true); } }