Fit an Image on a JPanel

Hi all ,

I have a JDialog and a JPanel on it.

Now i want to diaplay an image on this JPanel.

It should be fit on jpanel i.e. scaled image

I have path of image file. I have wrote the following code

Image IMG = new ImageIcon("path to image");

Graphics g = jPanel1.getGraphics();

g.drawImage(IMG,0,0,jPanel1);

How do i do ?

thanks

[390 byte] By [nav_ninia] at [2007-11-27 10:53:05]
# 1

You may find some useful info on scaling here:

http://java.sun.com/docs/books/tutorial/2d/images/drawimage.html

petes1234a at 2007-7-29 11:41:54 > top of Java-index,Java Essentials,Java Programming...