/*
 *  ===========================================================
 *  DemoTurtle.java : Swing applet containing a text string
 *  and image. Notice how the URL is contructed for download of
 *  the image over the net.
 *
 *  Written By : Mark Austin                     February, 2001
 *  ===========================================================
 */

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.SwingUtilities;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.net.URL;

public class DemoTurtle extends JApplet {

    URL codeBase;   // used for browser version only....
    URL turtleURL;  // URL for turtle image ...

    public void init() {

        // 1. Get a reference to the content pane of the applet.

        Container contentPane = getContentPane();

        // 2. Construct URL for image....

        codeBase = getCodeBase();
        try {
           turtleURL = new URL( codeBase, "Turtle.jpg");
        } catch ( java.net.MalformedURLException e ) {
           System.out.println("Badly specified URL!!");
        }

        // 3. Download and save image icon ....

        ImageIcon turtleImage = new ImageIcon( turtleURL );

        // 4. Create a label with an icon and text.

        JLabel label = new JLabel("Here is the UMD turtle ...", // text
                                  turtleImage,                  // turtle icon
                                  JLabel.CENTER);               // horiz. position

        // 5. Add the label to the applet's content pane.

        contentPane.add(label);
    }
}
