All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.ImageIcon

java.lang.Object
   |
   +----com.sun.java.swing.ImageIcon

public class ImageIcon
extends Object
implements Icon, Serializable
An implementation of the Icon interface that paints Icons from Images. Images that are created from a URL or filename are preloaded using MediaTracker to monitor the loaded state of the image.

Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.


Variable Index

 o component
 o tracker

Constructor Index

 o ImageIcon()
Creates an uninitialized image icon.
 o ImageIcon(byte[])
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG.
 o ImageIcon(byte[], String)
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG.
 o ImageIcon(Image)
Creates an ImageIcon from the image.
 o ImageIcon(Image, String)
Creates an ImageIcon from the image.
 o ImageIcon(String)
Creates an ImageIcon from the specified file.
 o ImageIcon(String, String)
Creates an ImageIcon from the specified file.
 o ImageIcon(URL)
Creates an ImageIcon from the specified URL.
 o ImageIcon(URL, String)
Creates an ImageIcon from the specified URL.

Method Index

 o getDescription()
Get the description of the image.
 o getIconHeight()
Get the height of the Icon
 o getIconWidth()
Get the width of the Icon
 o getImage()
Returns the Icon's Image
 o getImageLoadStatus()
Returns the status of the image loading operation.
 o getImageObserver()
Return the umage observer for the image
 o loadImage(Image)
Wait for the image to load
 o paintIcon(Component, Graphics, int, int)
Paints the Icon
 o setDescription(String)
Set the description of the image.
 o setImage(Image)
Set the image displayed by this icon.
 o setImageObserver(ImageObserver)
Set the image observer for the image.

Variables

 o component
 protected static final Component component
 o tracker
 protected static final MediaTracker tracker

Constructors

 o ImageIcon
 public ImageIcon(String filename,
                  String description)
Creates an ImageIcon from the specified file. The image will be preloaded by using MediaTracker to monitor the loading state of the image.

Parameters:
filename - the name of the file containing the image
description - a brief textual description of the image
 o ImageIcon
 public ImageIcon(String filename)
Creates an ImageIcon from the specified file. The image will be preloaded by using MediaTracker to monitor the loading state of the image.

 o ImageIcon
 public ImageIcon(URL location,
                  String description)
Creates an ImageIcon from the specified URL. The image will be preloaded by using MediaTracker to monitor the loaded state of the image.

Parameters:
URL - the URL for the image
description - a brief textual description of the image
 o ImageIcon
 public ImageIcon(URL location)
Creates an ImageIcon from the specified URL. The image will be preloaded by using MediaTracker to monitor the loaded state of the image.

 o ImageIcon
 public ImageIcon(Image image,
                  String description)
Creates an ImageIcon from the image.

Parameters:
image - the image
description - a brief textual description of the image
 o ImageIcon
 public ImageIcon(Image image)
Creates an ImageIcon from the image.

 o ImageIcon
 public ImageIcon(byte imageData[],
                  String description)
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class.

Parameters:
imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF or JPEG.
description - a brief textual description of the image
See Also:
createImage
 o ImageIcon
 public ImageIcon(byte imageData[])
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF or JPEG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class.

Parameters:
an - array of pixels in an image format supported by the AWT Toolkit, such as GIF or JPEG.
See Also:
createImage
 o ImageIcon
 public ImageIcon()
Creates an uninitialized image icon.

Methods

 o loadImage
 protected void loadImage(Image image)
Wait for the image to load

 o getImageLoadStatus
 public int getImageLoadStatus()
Returns the status of the image loading operation.

Returns:
the loading status as defined by java.awt.MediaTracker.
See Also:
ABORTED, ERRORED, COMPLETE
 o getImage
 public Image getImage()
Returns the Icon's Image

 o setImage
 public void setImage(Image image)
Set the image displayed by this icon.

 o getDescription
 public String getDescription()
Get the description of the image. This is meant to be a brief textual description of the object. For example, it might be presented to a blind user to give an indication of the purpose of the image.

 o setDescription
 public void setDescription(String description)
Set the description of the image. This is meant to be a brief textual description of the object. For example, it might be presented to a blind user to give an indication of the purpose of the image.

 o paintIcon
 public synchronized void paintIcon(Component c,
                                    Graphics g,
                                    int x,
                                    int y)
Paints the Icon

 o getIconWidth
 public int getIconWidth()
Get the width of the Icon

 o getIconHeight
 public int getIconHeight()
Get the height of the Icon

 o setImageObserver
 public void setImageObserver(ImageObserver observer)
Set the image observer for the image. Set this property if the ImageIcon contains an animated GIF. For example:
     icon = new ImageIcon(...)
     button.setImage(icon);
     icon.setImageObserver(button);
 

 o getImageObserver
 public ImageObserver getImageObserver()
Return the umage observer for the image


All Packages  Class Hierarchy  This Package  Previous  Next  Index