import java.applet.Applet; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Tekst2 extends Applet implements ActionListener{ TextField pikkus=new TextField(" 100 "); Button nupp=new Button(" OK "); public void init(){ add(pikkus); add(nupp); nupp.addActionListener(this); } public void actionPerformed(ActionEvent e){ int nr=Integer.parseInt(pikkus.getText().trim()); Graphics g=this.getGraphics(); g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.black); g.drawRect(10, 50, nr, nr); } }