import java.awt.*;
import java.awt.image.*;
import java.applet.Applet;

public class pics extends java.applet.Applet
{
    Image Simpsons1;
    Image S1Thumb;
    Image Simpsons2;
    Image S2Thumb;
    Image StarWars;
    Image SWThumb;
    int x = 0;
    int y = 0;
    boolean simp1;
    boolean simp2;
    boolean SW;
    MediaTracker Tracker;


 public void init()
 {

    Simpsons1 = getImage (getDocumentBase(), "simp2.jpg");
    S1Thumb = getImage (getDocumentBase(), "simp2th.jpg");
    Simpsons2 = getImage (getDocumentBase(), "homer2.jpg");
    S2Thumb = getImage (getDocumentBase(), "homer2th.jpg");
    StarWars = getImage (getDocumentBase(), "xwt11.jpg");
    SWThumb = getImage (getDocumentBase(), "xwt11th.jpg");

    Tracker = new MediaTracker(this);
    Tracker.addImage(Simpsons1,0);
    Tracker.addImage(S1Thumb,1);
    Tracker.addImage(Simpsons2,2);
    Tracker.addImage(S2Thumb,3);
    Tracker.addImage(StarWars,4);
    Tracker.addImage(SWThumb,5);
    showStatus("Please wait for the images of the 'Image And Thumbnail Applet'");
    try
    {
        Tracker.waitForAll();
    }
    catch(InterruptedException e)
    {
        return;
    }
    showStatus("Have fun!!");
 }

 public void paint(Graphics g)
 {
    g.setColor (new Color (1.0f,1.0f,1.0f));
    g.drawRect (0, 0, 400, 300);
    g.fillRect (0, 0, 400, 300);
    g.drawImage(S1Thumb, 0, 10, this);
    if (simp1)
    {
        g.drawImage(Simpsons1, 100, 10, this);
        simp1 = false;
    }

    g.drawImage(S2Thumb, 0, 100, this);
    if (simp2)
    {
        g.drawImage (Simpsons2, 100, 10, this);
        simp2 = false;
    }

    g.drawImage (SWThumb, 0, 200, this);
    if (SW)
    {
        g.drawImage (StarWars, 100, 10, this);
        SW = false;
    }

    //g.drawString("x: "+x+" y: "+y , x, y);


 }

 public boolean mouseDown (Event evt, int x_pos, int y_pos)
 {
    if (x_pos > 0 && x_pos < 64 && y_pos > 10 && y_pos < 64)
    {
        simp1 = true;
        repaint(100, 10, 400, 300);
    }

    if (x_pos > 0 && x_pos < 64 && y_pos > 100 && y_pos < 164)
    {
        simp2 = true;
        repaint(100, 10, 400, 300);
    }

    if (x_pos > 0 && x_pos < 65 && y_pos > 200 && y_pos < 284)
    {
        SW = true;
        repaint(100, 10, 400, 300);
    }



    //x = x_pos;
    //y = y_pos;
   // repaint();
    return true;
 }




}

