import java.applet.Applet; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class paike extends Applet implements ActionListener{ TextField kiiri=new TextField(5); Button nupp=new Button(" Joonista "); public void init(){ add(kiiri); add(nupp); nupp.addActionListener(this); kiiri.addActionListener(this); } public void actionPerformed(ActionEvent e){ int nr=Integer.parseInt(kiiri.getText().trim()); Graphics g=this.getGraphics(); g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.black); g.drawOval(100, 150, 40, 40); g.setColor(Color.yellow); g.fillOval(100, 150, 40, 40); int r = 80; int x = 0; int y = r; double nurgavahe = ( 2*Math.PI ) / nr; double nurk=0; for (int k=0; k<=nr; k++){ g.setColor(Color.black); g.drawLine(120, 170, 120-x, 170+y); x = (int)Math.round(Math.sin(nurk)*r); y = (int)Math.round(Math.cos(nurk)*r); nurk = nurk+nurgavahe; } } }