Reizing image in JLabel

heyy friends am adding an image in JLabel but it occupies almost 3/4th of screen when i tried using setting dimension the image is getting cropped and displayed .. can anyone give me a soln for resizing without affecting the content of img
[246 byte] By [haiprathi@gmail.coma] at [2007-11-27 6:40:59]
# 1

you can scale down the image first.

(Add) assume you are using ImageIcon:

ImageIcon icon = ...;

int targetH, targetW;

Image img = icon.getImage();

img = img.getScaledInstance(targetH, targetW, Image.SCALE_SMOOTH);

icon.setImage(img);

JLabel l = new JLabel(icon);

Message was edited by:

j_shadinata

j_shadinataa at 2007-7-12 18:10:25 > top of Java-index,Desktop,Core GUI APIs...