dcsimg

How can I resize an ImageIcon?

Sandip Chitale

ImageIcon is not a java.awt.Component subclass thus you cannot resize it directly. You have to use the following variant of java.awt.Graphics.drawImage -

public abstract boolean drawImage(Image img,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  ImageObserver observer)

You can get the image out of Image Icon using getImage() method.