How do I get an icon to resize to the size of the label automatically?

Hello, I'm using Netbeans 6.5

I'm having a problem where the image file I insert into the label doesn't readjust itself to the label, but instead stays it's original size. I'm doing this through the visual interface Netbeans provides. If there's anyway to fix this through that interface, I'd prefer it to be done that way. If it can be only done through code though, I'll accept that as well.

Thank you!


  • Hi i tried this code just use and c this...
    bye from shan

    Image img = Toolkit.getDefaultToolkit().createImage(file.getPath()).getScaledInstance(90, 91, 0);
    ImageIcon ic = new ImageIcon(img);
  • [size=4][b][b]picture is my jLabel
    and 90,91,0 is width, height,and hints.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion