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.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.