import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
public class ImageApplet extends JApplet
{	private Image img;
	private int larghezza, altezza;
	private Osservatore oss = new Osservatore();
	public class MioPanel extends JPanel
	{	public MioPanel()
		{	setBackground(Color.yellow);
		}
		public void paintComponent(Graphics g)
		{	super.paintComponent(g);
			g.fillRect(5, 5, larghezza+10, altezza+10);
			g.drawImage(img, 10, 10, oss);
			g.drawImage(img, 180, 80, 50,50, oss);
		}
	}
	private MioPanel p;
	public void init() 
	{	img = getImage(getCodeBase(), "imgs/java.gif");
		larghezza = img.getWidth(oss);
		altezza = img.getHeight(oss);
		p = new MioPanel();
		getContentPane().add(p);
	}
	private class Osservatore implements ImageObserver 
	{ public boolean imageUpdate(Image img, 
														int infoflags, 
														int x, int y, 
														int width, int height) 
		{	if((infoflags & WIDTH) != 0)
				larghezza = width;
			if((infoflags & HEIGHT) != 0)
				altezza = height;
			repaint();
			if((infoflags & (ALLBITS|ABORT)) != 0)
				return false;
			return true;
		}
	}
}
