Sir.Geek Sir.Geek - 8 months ago 76
Java Question

How to resize an image set as an icon in java netbeans IDE 8.1

I am very new to Java, I have learned how to add images in a

as an icon in
, but the image acts in a notorious way that is it becomes too big in a way that only part of it can be seen.

I have tried various ways but I didn't solve it, and most of the answers explain it by coding, a way which I am not familiar with.

So I am humbly asking for help on how i can make that image to fit on a small jLabel or if there is any other way to accomplish this. (The images are for a computer voting system that has has an image a check box and name.)


you can resize the image in the IDE...

enter image description here

or in SourceCode:

BufferedImage img;
try {
    img = File("strawberry.jpg"));
} catch (IOException e) {

BufferedImage dimg = img.getScaledInstance(64, 64,        Image.SCALE_SMOOTH);

ImageIcon imageIcon = new ImageIcon(dimg);