import java.applet.*; import java.awt.event.*; import java.awt.*; public class Ringid extends Applet implements AdjustmentListener { public void init(){ setLayout(new BorderLayout()); add(sb, BorderLayout.NORTH); sb.addAdjustmentListener(this); } public static void main(String argumendid[]){ Frame f=new Frame("Ringid, nagu ise tahad!"); f.setSize(400, 400); Applet ap=new Ringid(); ap.init(); f.add(ap); f.setVisible(true); } Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL, 1, 10, 0, 110); int arv = 1, x, y; double nurk; double kraad=Math.PI/180; int raadius = 100; public void paint(Graphics g) { if(arv>0) { nurk = (360.0/arv)*kraad; g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.black); for(int i=1; i<=arv; i++) { x = (int)(raadius*Math.cos(nurk*i))+200; y = (int)(raadius*Math.sin(nurk*i))+200; g.fillOval(x, y, 10, 10); } } g.drawString("Hetkel on nurkade arv: "+arv, 20, 50); } public void adjustmentValueChanged(AdjustmentEvent e){ arv = (int)sb.getValue(); repaint(); } }