ΣΚΙΑ

import java.applet.*;
import java.awt.*;
import java.awt.Color;
 
public class Skia extends Applet implements Runnable {
 
    
    int width = 10, height = 360;
 
    int i = 0;
    Thread t = null;
    boolean threadSuspended;
 
    // Executed when the applet is first created.
    public  void   init() {
        System.out.println("init(): begin");
        //width = getSize().width;
        // height = getSize().height;
        setBackground(Color.decode("#fffff0"));
        // System.out.println("init(): end");
    }
 
    // Executed when the applet is destroyed.
    public void destroy() {
        System.out.println("destroy()");
    }
 
    // Executed after the applet is created; and also whenever
    // the browser returns to the page containing the applet.
    public void start() {
        System.out.println("start(): begin");
        if (t == null) {
            System.out.println("start(): creating thread");
            t = new Thread(this);
            System.out.println("start(): starting thread");
            threadSuspended = false;
            t.start();
        } else if (threadSuspended) {
            threadSuspended = false;
            System.out.println("start(): notifying thread");
            synchronized (this) {
                notify();
            }
        }
        System.out.println("start(): end");
    }
 
    // Executed whenever the browser leaves the page containing the applet.
    public void stop() {
        // System.out.println("stop(): begin");
        threadSuspended = true;
    }
 
    // Executed within the thread that this applet created.
    public void run() {
        //  System.out.println("run(): begin");
        try {
            while (true) {
                // System.out.println("run(): awake");
 
                // Here's where the thread does some work
                i = i+10;  // this is shorthand for "i = i+1;"
                if (i == 2000) {
                    i = 0;
                }
                showStatus("i is " + i);
 
                // Now the thread checks to see if it should suspend itself
                if (threadSuspended) {
                    synchronized (this) {
                        while (threadSuspended) {
                           // System.out.println("run(): waiting");
                         //   wait();
                        }
                    }
                }
                // System.out.println("run(): requesting repaint");
                repaint();
                //   System.out.println("run(): sleeping");
                t.sleep(100);  // interval given in milliseconds
            }
        } catch (InterruptedException e) {
        }
        //System.out.println("run(): end");
    }
 
    // Executed whenever the applet is asked to redraw itself.
    
    
     public void paint (Graphics g) {
      //super.paintComponent(g);
       
                // System.out.println("paint()");
               
         g.setColor(Color.yellow);
         g.fillOval(width+i/100 , height-40+i/50 , 40-i/50, 80-2*i/50);
        //g.setColor(Color.yellow);
        // g.fillOval(width , height-40 , 40, 80);
         g.setColor(Color.ORANGE);
         g.fillOval(width+400 , height-120 , 120, 240);
         
         g.setColor(Color.pink);
         g.fillOval(width+940+i*3/200 , height-360+3*i/100 , 360-3*i/100, 720-3*i/50);
        // g.fillOval(width+940 , height-360 , 360, 720);
         g.setColor(Color.blue);
         g.fillOval(width+1000-i*3/200 , height-240-i*3/100 , 240+3*i/100, 480+3*i/50);
            
        // g.setColor(Color.green);
        // g.fillOval(width+940 , height-360 , 360, 720);
               
         g.setColor(Color.blue);
         g.drawLine(width+20 , height - 40+i/50 , width+1120  , height -240-3*i/100);
         g.setColor(Color.blue);
         g.drawLine(width+20 , height + 40-i/50 , width+1120  , height +240+3*i/100);      
 
         g.setColor(Color.red);
         g.drawLine(width +20, height -40+i/50 , width +1120, height + 360-3*i/100);
         g.setColor(Color.red);
         g.drawLine(width +20, height +40-i/50 , width +1120, height - 360+3*i/100);
         
     }      
 
}