import java.awt.*;

        // Provide a Frame for a ScrollPane which contains
        // an ImageCanvas displaying Image.
public class ScrollPaneFrame extends Frame {
    ScrollPaneFrame(Image i){
        final int initialWidth = 200, initialHeight = 200;
        setSize(initialWidth,initialHeight);

        // Only include scrollbars if necessary.
        ScrollPane pane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
        // Get the horizontal adjustment controls and set the
        // scrolling increments.
        final int hIncrement = 5, vIncrement = 2;
        Adjustable horizontal = pane.getHAdjustable(),
                   vertical = pane.getVAdjustable();
        horizontal.setUnitIncrement(hIncrement);
        vertical.setUnitIncrement(vIncrement);

        // Add the component to be scrolled to the scroll pane.
        Canvas canvas = new ImageCanvas(i);
        pane.add(canvas);
        // Add the scroll pane to the frame.
        add(pane);
    }
}
