On my JFrame, I am using the following code to display an image on the Panel :
ImageIcon img= new ImageIcon(\"res.png\");
jLabel.setIcon(img);
easywayprogramming.com how to resize imageicon in java
When we apply image icon to any component like button, label or panel, it not apply properly because of size of that image. We can resize that image icon in two ways.
first way:
Image img = myIcon2.getImage(); Image newimg = img.getScaledInstance(230, 310, java.awt.Image.SCALE_SMOOTH);
newIcon = new ImageIcon(newimg);
second way:
Image img = myIcon2.getImage(); BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
newIcon = new ImageIcon(bi);
Try following link easywayprogramming.blogspot.in: easywayprogramming.blogspot.in ho to resize image icon in java