import java.applet.Applet; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class circle extends Applet implements ActionListener{ Button nupp1=new Button(" radius "); TextField pikkus1=new TextField(" 0 "); Button nupp2=new Button(" area "); TextField pikkus2=new TextField(" 0 ",6); public void init(){ add(nupp1); add(pikkus1); add(nupp2); add(pikkus2); nupp1.addActionListener(this); nupp2.addActionListener(this); } public void actionPerformed(ActionEvent e){ int nr=Integer.parseInt(pikkus1.getText().trim()); Graphics g=this.getGraphics(); g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.blue); g.fillOval(10, 50, nr*5, nr*5); pikkus2.setText(numbriks(pikkus1)*numbriks(pikkus1)*3.14+""); } int numbriks(TextField tf){ return Integer.parseInt(tf.getText().trim()); } }