import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Tekst2c extends Frame implements ActionListener{ TextField pikkus=new TextField(" 100 "); Button nupp=new Button(" OK "); public Tekst2c(){ setTitle("Ruudu joonistamine"); setLayout(new FlowLayout()); //raami vaikimisi paigutushalduriks on add(pikkus); //servadesse ning keskele suunav BorderLayout add(nupp); nupp.addActionListener(this); setSize(300, 300); setVisible(true); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); } 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, 70, nr, nr); //ka pealkirjariba arvestatakse pinna sisse } public static void main(String argumendid[]){ new Tekst2c(); } }