import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
class ImageFrame extends JFrame
{	private Image img;
	private ImageIcon ic;
	private int larghezza, altezza;
	class MioPanel extends JPanel
	{	public void paintComponent(Graphics g)
		{	super.paintComponent(g);
			g.fillRect(5, 5, larghezza+10, altezza+10);
			g.drawImage(img, 10, 10, null);
			g.drawImage(img, 180, 80, 50, 50, null);
		}
	}
	private MioPanel p;
	ImageFrame() 
	{	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		ic = new ImageIcon("imgs/java.gif");
		img = ic.getImage();
		larghezza = img.getWidth(null);
		altezza = img.getHeight(null);
		p = new MioPanel();
		p.setBackground(Color.green);
		getContentPane().add(p);
	}
}

public class ProvaImage	
{	public static void main(String[] args) 
	{	ImageFrame fr = new ImageFrame();
		fr.setSize(200, 200);
		fr.setVisible(true);
	}
}
