Java Swing Tutorial - Java ImageIcon.getIconWidth()








Syntax

ImageIcon.getIconWidth() has the following syntax.

public int getIconWidth()

Example

In the following code shows how to use ImageIcon.getIconWidth() method.

//from   w ww .  j a  va  2 s  . c o  m
import javax.swing.ImageIcon;

public class Main {
  public static void main(String[] argv) throws Exception {

    ImageIcon icon = new ImageIcon("image.gif");
    icon.setDescription("Description of Image");
    
    System.out.println(icon.getIconWidth());
  }
}