| 
 |   | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--javax.swing.ImageIcon
Safe: 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.
For further information and examples of using image icons, see How to Use Icons in The Java Tutorial.
 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 applications running
 the same version of Swing.  As of 1.4, support for long term storage
 of all JavaBeansTM
 has been added to the java.beans package.
 Please see java.beans.XMLEncoder.
| Field Summary | |
| private  javax.swing.ImageIcon.AccessibleImageIcon | accessibleContext--- Accessibility Support --- | 
| protected static Component | component | 
| (package private)  String | description | 
| private  String | filename | 
| (package private)  int | height | 
| (package private)  Image | image | 
| (package private)  java.awt.image.ImageObserver | imageObserver | 
| (package private)  int | loadStatus | 
| private  URL | location | 
| private static int | mediaTrackerIDId used in loading images from MediaTracker. | 
| protected static MediaTracker | tracker | 
| (package private)  int | width | 
| Constructor Summary | |
| ImageIcon()Enabled: Creates an uninitialized image icon. | |
| ImageIcon(byte[] imageData)Enabled: 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. | |
| ImageIcon(byte[] imageData,
          String description)Enabled: 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. | |
| ImageIcon(Image image)Enabled: Creates an ImageIcon from an image object. | |
| ImageIcon(Image image,
          String description)Enabled: Creates an ImageIcon from the image. | |
| ImageIcon(String filename)Suppressed: Creates an ImageIcon from the specified file. | |
| ImageIcon(String filename,
          String description)Suppressed: Creates an ImageIcon from the specified file. | |
| ImageIcon(URL location)Enabled: Creates an ImageIcon from the specified URL. | |
| ImageIcon(URL location,
          String description)Enabled: Creates an ImageIcon from the specified URL. | |
| Method Summary | |
|  AccessibleContext | getAccessibleContext()Suppressed: Gets the AccessibleContext associated with this ImageIcon. | 
|  String | getDescription()Enabled: Gets the description of the image. | 
|  int | getIconHeight()Enabled: Gets the height of the icon. | 
|  int | getIconWidth()Enabled: Gets the width of the icon. | 
|  Image | getImage()Enabled: Returns this icon's Image. | 
|  int | getImageLoadStatus()Enabled: Returns the status of the image loading operation. | 
|  java.awt.image.ImageObserver | getImageObserver()Enabled: Returns the image observer for the image. | 
| private  int | getNextID()Returns an ID to use with the MediaTracker in loading an image. | 
| protected  void | loadImage(Image image)Loads the image, returning only when the image is loaded. | 
|  void | paintIcon(Component c,
          Graphics g,
          int x,
          int y)Suppressed: Paints the icon. | 
| private  void | readObject(ObjectInputStream s) | 
| static ImageIcon | run(File file)Added: Instead of the security-breaking suppressed 'new(String)'. | 
| static ImageIcon | run(File file,
    String description)Added: Instead of the security-breaking suppressed 'new(String, String)'. | 
|  void | setDescription(String description)Enabled: Sets the description of the image. | 
|  void | setImage(Image image)Enabled: Sets the image displayed by this icon. | 
|  void | setImageObserver(java.awt.image.ImageObserver observer)Enabled: Sets the image observer for the image. | 
|  String | toString()Suppressed: Returns a string representation of this image. | 
| private  void | writeObject(ObjectOutputStream s) | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
private transient String filename
private transient URL location
transient Image image
transient int loadStatus
java.awt.image.ImageObserver imageObserver
String description
protected static final Component component
protected static final MediaTracker tracker
private static int mediaTrackerID
int width
int height
private javax.swing.ImageIcon.AccessibleImageIcon accessibleContext
| Constructor Detail | 
public ImageIcon(String filename,
                 String description)
filename - the name of the file containing the imagedescription - a brief textual description of the imageImageIcon(String)public ImageIcon(String filename)
    new ImageIcon("images/myImage.gif") 
 The description is initialized to the filename string.
filename - a String specifying a filename or pathgetDescription()
public ImageIcon(URL location,
                 String description)
location - the URL for the imagedescription - a brief textual description of the imageImageIcon(String)public ImageIcon(URL location)
location - the URL for the imagegetDescription()
public ImageIcon(Image image,
                 String description)
image - the imagedescription - a brief textual description of the imagepublic ImageIcon(Image image)
image - the imagegetDescription(), 
java.awt.Image#getProperty
public ImageIcon(byte[] imageData,
                 String description)
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 imagejava.awt.Toolkit#createImagepublic ImageIcon(byte[] imageData)
imageData - an array of pixels in an image format supported by
                   the AWT Toolkit, such as GIF or JPEGjava.awt.Toolkit#createImage, 
getDescription(), 
java.awt.Image#getPropertypublic ImageIcon()
| Method Detail | 
protected void loadImage(Image image)
image - the imageprivate int getNextID()
public int getImageLoadStatus()
java.awt.MediaTracker#ABORTED, 
java.awt.MediaTracker#ERRORED, 
java.awt.MediaTracker#COMPLETEpublic Image getImage()
Image.
Image object for this ImageIconpublic void setImage(Image image)
image - the imagepublic String getDescription()
public void setDescription(String description)
description - a brief textual description of the image
public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
x, y)
 in the coordinate space of the graphics context g.
 If this icon has no image observer,
 this method uses the c component
 as the observer.
paintIcon in interface Iconc - the component to be used as the observer
          if this icon has no image observerg - the graphics contextx - the X coordinate of the icon's top-left cornery - the Y coordinate of the icon's top-left cornerpublic int getIconWidth()
getIconWidth in interface Iconpublic int getIconHeight()
getIconHeight in interface Iconpublic void setImageObserver(java.awt.image.ImageObserver observer)
     icon = new ImageIcon(...)
     button.setIcon(icon);
     icon.setImageObserver(button);
 
observer - the image observerpublic java.awt.image.ImageObserver getImageObserver()
public String toString()
toString in class Object
private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException
ClassNotFoundException
IOException
private void writeObject(ObjectOutputStream s)
                  throws IOException
IOExceptionpublic AccessibleContext getAccessibleContext()
getAccessibleContext in interface Accessible
public static ImageIcon run(File file,
                            String description)
public static ImageIcon run(File file)
| 
 |   | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
