MOLE stacking
arcgissamples\defensesolutions\PictureViewer.java
/* Copyright 2010 ESRI
* 
* All rights reserved under the copyright laws of the United States
* and applicable international laws, treaties, and conventions.
* 
* You may freely redistribute and use this sample code, with or
* without modification, provided you include the original copyright
* notice and use restrictions.
* 
* See the use restrictions.
* 
*/
package arcgissamples.defensesolutions;

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

/**
 * Simple JFrame to display an image
 *
 */
public class PictureViewer extends JFrame {
  private static final long serialVersionUID = 1L;
  Dimension size;
    Image m_image;

    int imageWidth, imageHeight;
    public PictureViewer(Image image) {
        super("image");
        try{
            m_image = image;
            MediaTracker mt = new MediaTracker(this);
            mt.addImage(image, 0);
            try {
                mt.waitForID(0);
            } catch (InterruptedException e) {}

            imageWidth = image.getWidth(this);
            imageHeight = image.getHeight(this);
            setSize(imageWidth, imageHeight);
            size = new Dimension(imageWidth, imageHeight);
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        }catch(Exception e){e.printStackTrace();}
    }

    public Dimension getPreferredSize() {
        return getMinimumSize();
    }

    public Dimension getMinimumSize() {
        return size;
    }

    public void paint(java.awt.Graphics g) {
        setSize(imageWidth, imageHeight);
        Insets in = getInsets();
        g.translate(in.left, in.top);
        g.drawImage(m_image, 0, 0, this);
   }






}