import javax.swing.*;
import java.awt.*;
import java.awt.Image;
import java.awt.MediaTracker;

public class TJScrollPane extends JApplet {
    // 1. Create a scrollpane object and other necesary objects
    JScrollPane scrollPane = null;
    JLabel label = null;
    JPanel panel = null;
    Icon icon = null;
    Image image1;
    MediaTracker tracker;

    public void init() {

	// 2. Get a handle on the JApplet's container.
	Container container = getContentPane();
	container.setLayout(new GridLayout(1,1));

        image1 = getImage(getCodeBase(), "tiger_siberian.jpg");

        tracker = new MediaTracker(this);
        tracker.addImage(image1, 1);

        this.showStatus("Loading images");
        try {
            tracker.waitForID(1);
        } catch (InterruptedException e) {
            ;
        }
        if (tracker.isErrorID(1)) {
            this.showStatus("Error loading image.");
            this.stop();
        }

	// 3. Create a Swing label and a panel for double buffering
	//icon = new ImageIcon("tiger_siberian.jpg");
	//icon = new ImageIcon( image1 );
	//icon = new ImageIcon( "http://mina.sdsc.edu/swing/JScrollPane/tiger_siberian.jpg" );
	icon = new ImageIcon( "http://www.sdsc.edu/~damartin/bionome/JScrollPane/tiger_siberian.jpg" );
	label = new JLabel(icon);
	panel = new JPanel();
	panel.add(label);

	// 4. Create a scroll pane and add the panel to it.
	
	scrollPane = new JScrollPane(panel, 
		JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
		JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

	// 5. Add the scroll pane to the contentpane of JApplet.
	container.add(scrollPane);
    }
}
	
