import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Naerunagu extends Applet implements AdjustmentListener{ Scrollbar sb=new Scrollbar(Scrollbar.VERTICAL, 100, 100, 2, 3000); public Naerunagu(){ setLayout(new BorderLayout()); add(sb, BorderLayout.WEST); sb.addAdjustmentListener(this); } void joonistaRingid(Graphics g, int x, int y, int laius, int korgus){ g.drawOval(x, y, laius, korgus); g.drawArc(x+laius/6, y+korgus/3, laius*2/3, korgus/2, 0, -180); //suu g.drawArc(x+laius/2-5, y+korgus/3, laius/12, korgus/8, 0, -180); //nina if(laius>10){ joonistaRingid(g, x+laius/5, y+korgus/5, laius/6, korgus/6); // parem silm joonistaRingid(g, x+laius*4/6, y+korgus/5, laius/6, korgus/6); // vasak silm } } public void paint(Graphics g){ int nr=sb.getValue(); joonistaRingid(g, 300-nr, 300-nr, 2*nr, 2*nr); } public void adjustmentValueChanged(AdjustmentEvent e){ repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("Arvestusülesanne 'Naerunägu', Versioon 1, by -Rünno Allikivi-"); f.add(new Naerunagu()); f.setSize(600, 600); f.setVisible(true); f.addWindowListener(new Raami2kuular()); } } class Raami2kuular extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.out.println(""); System.exit(0); } }