Package Summary  Overview Summary

class:ImageIcon [CHANGED]

  • All Implemented Interfaces:
    Serializable, Accessible, Icon


    public class ImageIcon
    extends Object
    implements Icon, Serializable, Accessible
    
    An implementation of the Icon interface that paints Icons from Images. Images that are created from a URL, filename or byte array 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 JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.

    Since:
    1.2
    See Also:
    Serialized Form
  • All Implemented Interfaces:
    Serializable, Accessible, Icon


    public class ImageIcon
    extends Object
    implements Icon, Serializable, Accessible
    
    An implementation of the Icon interface that paints Icons from Images. Images that are created from a URL, filename or byte array 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 JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.

  • All Implemented Interfaces:
    Serializable, Accessible, Icon


    public class ImageIcon
    extends Object
    implements Icon, Serializable, Accessible
    
    An implementation of the Icon interface that paints Icons from Images. Images that are created from a URL, filename or byte array 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 JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.

    Since:
    1.2
    See Also:
    Serialized Form

field:component [NONE]

  • component

    @Deprecated
    protected static final Component component
    Deprecated. since 1.8
    Do not use this shared component, which is used to track image loading. It is left for backward compatibility only.

field:tracker [NONE]

  • tracker

    @Deprecated
    protected static final MediaTracker tracker
    Deprecated. since 1.8
    Do not use this shared media tracker, which is used to load images. It is left for backward compatibility only.

constructor:ImageIcon(java.lang.String, java.lang.String) [CHANGED]

  • ImageIcon

    public ImageIconpublic 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
    See Also:
    ImageIcon(String)
  • 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
    See Also:
    ImageIcon(String)
  • 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
    See Also:
    ImageIcon(String)

constructor:ImageIcon(java.lang.String) [CHANGED]

  • ImageIcon

    @ConstructorProperties(value="description")
    public ImageIconpublic 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. The specified String can be a file name or a file path. When specifying a path, use the Internet-standard forward-slash ("/") as a separator. (The string is converted to an URL, so the forward-slash works on all systems.) For example, specify:
        new ImageIcon("images/myImage.gif") 
    The description is initialized to the filename string.
    Parameters:
    filename - a String specifying a filename or path
    See Also:
    getDescription()
  • ImageIcon

    @ConstructorProperties(value="description")
    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. The specified String can be a file name or a file path. When specifying a path, use the Internet-standard forward-slash ("/") as a separator. (The string is converted to an URL, so the forward-slash works on all systems.) For example, specify:
        new ImageIcon("images/myImage.gif") 
    The description is initialized to the filename string.
    Parameters:
    filename - a String specifying a filename or path
    See Also:
    getDescription()
  • ImageIcon

    @ConstructorProperties("description")
    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. The specified String can be a file name or a file path. When specifying a path, use the Internet-standard forward-slash ("/") as a separator. (The string is converted to an URL, so the forward-slash works on all systems.) For example, specify:
        new ImageIcon("images/myImage.gif") 
    The description is initialized to the filename string.
    Parameters:
    filename - a String specifying a filename or path
    See Also:
    getDescription()

constructor:ImageIcon(java.net.URL, java.lang.String) [CHANGED]

  • ImageIcon

    public ImageIconpublic 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:
    location - the URL for the image
    description - a brief textual description of the image
    See Also:
    ImageIcon(String)
  • 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:
    location - the URL for the image
    description - a brief textual description of the image
    See Also:
    ImageIcon(String)
  • 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:
    location - the URL for the image
    description - a brief textual description of the image
    See Also:
    ImageIcon(String)

constructor:ImageIcon(java.net.URL) [CHANGED]

  • ImageIcon

    public ImageIconpublic 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. The icon's description is initialized to be a string representation of the URL.
    Parameters:
    location - the URL for the image
    See Also:
    getDescription()
  • 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. The icon's description is initialized to be a string representation of the URL.
    Parameters:
    location - the URL for the image
    See Also:
    getDescription()
  • 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. The icon's description is initialized to be a string representation of the URL.
    Parameters:
    location - the URL for the image
    See Also:
    getDescription()

constructor:ImageIcon(java.awt.Image, java.lang.String) [CHANGED]

  • ImageIcon

    public ImageIconpublic ImageIcon​(Image image,
                     String description)
    Creates an ImageIcon from the image.
    Parameters:
    image - the image
    description - a brief textual description of the image
  • 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
  • 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

constructor:ImageIcon(java.awt.Image) [CHANGED]

constructor:ImageIcon(byte[], java.lang.String) [CHANGED]

  • ImageIcon

    public ImageIconpublic 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, JPEG, or (as of 1.3) PNG. 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, JPEG, or (as of 1.3) PNG
    description - a brief textual description of the image
    See Also:
    Toolkit.createImage(java.lang.String)
  • 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, JPEG, or (as of 1.3) PNG. 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, JPEG, or (as of 1.3) PNG
    description - a brief textual description of the image
    See Also:
    Toolkit.createImage(java.lang.String)
  • 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, JPEG, or (as of 1.3) PNG. 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, JPEG, or (as of 1.3) PNG
    description - a brief textual description of the image
    See Also:
    Toolkit.createImage(java.lang.String)

constructor:ImageIcon(byte[]) [CHANGED]

  • ImageIcon

    public ImageIconpublic 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, JPEG, or (as of 1.3) PNG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class. If the resulting image has a "comment" property that is a string, then the string is used as the description of this icon.
    Parameters:
    imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
    See Also:
    Toolkit.createImage(java.lang.String), getDescription(), Image.getProperty(java.lang.String, java.awt.image.ImageObserver)
  • 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, JPEG, or (as of 1.3) PNG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class. If the resulting image has a "comment" property that is a string, then the string is used as the description of this icon.
    Parameters:
    imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
    See Also:
    Toolkit.createImage(java.lang.String), getDescription(), Image.getProperty(java.lang.String, java.awt.image.ImageObserver)
  • 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, JPEG, or (as of 1.3) PNG. Normally this array is created by reading an image using Class.getResourceAsStream(), but the byte array may also be statically stored in a class. If the resulting image has a "comment" property that is a string, then the string is used as the description of this icon.
    Parameters:
    imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
    See Also:
    Toolkit.createImage(java.lang.String), getDescription(), Image.getProperty(java.lang.String, java.awt.image.ImageObserver)

constructor:ImageIcon() [CHANGED]

  • ImageIcon

    public ImageIconpublic ImageIcon​()
    Creates an uninitialized image icon.
  • ImageIcon

    public ImageIcon()
    Creates an uninitialized image icon.
  • ImageIcon

    public ImageIcon​()
    Creates an uninitialized image icon.

method:loadImage(java.awt.Image) [CHANGED]

  • loadImage

    protected void loadImageprotected void loadImage​(Image image)
    Loads the image, returning only when the image is loaded.
    Parameters:
    image - the image
  • loadImage

    protected void loadImage(Image image)
    Loads the image, returning only when the image is loaded.
    Parameters:
    image - the image
  • loadImage

    protected void loadImage​(Image image)
    Loads the image, returning only when the image is loaded.
    Parameters:
    image - the image

method:getImageLoadStatus() [CHANGED]

method:getImage() [CHANGED]

  • getImage

    public Image getImage getImage​()
    Returns this icon's Image.
    Returns:
    the Image object for this ImageIcon
  • getImage

    public Image getImage()
    Returns this icon's Image.
    Returns:
    the Image object for this ImageIcon
  • getImage

    public Image getImage​()
    Returns this icon's Image.
    Returns:
    the Image object for this ImageIcon

method:setImage(java.awt.Image) [CHANGED]

  • setImage

    public void setImagepublic void setImage​(Image image)
    Sets the image displayed by this icon.
    Parameters:
    image - the image
  • setImage

    public void setImage(Image image)
    Sets the image displayed by this icon.
    Parameters:
    image - the image
  • setImage

    public void setImage​(Image image)
    Sets the image displayed by this icon.
    Parameters:
    image - the image

method:getDescription() [CHANGED]

  • getDescription

    public String getDescription getDescription​()
    Gets 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. The description may be null.
    Returns:
    a brief textual description of the image
  • getDescription

    public String getDescription()
    Gets 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. The description may be null.
    Returns:
    a brief textual description of the image
  • getDescription

    public String getDescription​()
    Gets 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. The description may be null.
    Returns:
    a brief textual description of the image

method:setDescription(java.lang.String) [CHANGED]

  • setDescription

    public void setDescriptionpublic void setDescription​(String description)
    Sets 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.
    Parameters:
    description - a brief textual description of the image
  • setDescription

    public void setDescription(String description)
    Sets 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.
    Parameters:
    description - a brief textual description of the image
  • setDescription

    public void setDescription​(String description)
    Sets 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.
    Parameters:
    description - a brief textual description of the image

method:paintIcon(java.awt.Component, java.awt.Graphics, int, int) [CHANGED]

  • paintIcon

    public void paintIconpublic void paintIcon​(Component c,
                          Graphics g,
                          int x,
                          int y)
    Paints the icon. The top-left corner of the icon is drawn at the point (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.
    Specified by:
    paintIcon in interface Icon
    Parameters:
    c - the component to be used as the observer if this icon has no image observer
    g - the graphics context
    x - the X coordinate of the icon's top-left corner
    y - the Y coordinate of the icon's top-left corner
  • paintIcon

    public void paintIcon(Component c,
                          Graphics g,
                          int x,
                          int y)
    Paints the icon. The top-left corner of the icon is drawn at the point (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.
    Specified by:
    paintIcon in interface Icon
    Parameters:
    c - the component to be used as the observer if this icon has no image observer
    g - the graphics context
    x - the X coordinate of the icon's top-left corner
    y - the Y coordinate of the icon's top-left corner
  • paintIcon

    public void paintIcon​(Component c,
                          Graphics g,
                          int x,
                          int y)
    Paints the icon. The top-left corner of the icon is drawn at the point (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.
    Specified by:
    paintIcon in interface Icon
    Parameters:
    c - the component to be used as the observer if this icon has no image observer
    g - the graphics context
    x - the X coordinate of the icon's top-left corner
    y - the Y coordinate of the icon's top-left corner

method:getIconWidth() [CHANGED]

  • getIconWidth

    public int getIconWidthpublic int getIconWidth​()
    Gets the width of the icon.
    Specified by:
    getIconWidth in interface Icon
    Returns:
    the width in pixels of this icon
  • getIconWidth

    public int getIconWidth()
    Gets the width of the icon.
    Specified by:
    getIconWidth in interface Icon
    Returns:
    the width in pixels of this icon
  • getIconWidth

    public int getIconWidth​()
    Gets the width of the icon.
    Specified by:
    getIconWidth in interface Icon
    Returns:
    the width in pixels of this icon

method:getIconHeight() [CHANGED]

  • getIconHeight

    public int getIconHeightpublic int getIconHeight​()
    Gets the height of the icon.
    Specified by:
    getIconHeight in interface Icon
    Returns:
    the height in pixels of this icon
  • getIconHeight

    public int getIconHeight()
    Gets the height of the icon.
    Specified by:
    getIconHeight in interface Icon
    Returns:
    the height in pixels of this icon
  • getIconHeight

    public int getIconHeight​()
    Gets the height of the icon.
    Specified by:
    getIconHeight in interface Icon
    Returns:
    the height in pixels of this icon

method:setImageObserver(java.awt.image.ImageObserver) [CHANGED]

  • setImageObserver

    public void setImageObserverpublic void setImageObserver​(ImageObserver observer)
    Sets the image observer for the image. Set this property if the ImageIcon contains an animated GIF, so the observer is notified to update its display. For example:
         icon = new ImageIcon(...)
         button.setIcon(icon);
         icon.setImageObserver(button);
     
    Parameters:
    observer - the image observer
  • setImageObserver

    public void setImageObserver(ImageObserver observer)
    Sets the image observer for the image. Set this property if the ImageIcon contains an animated GIF, so the observer is notified to update its display. For example:
         icon = new ImageIcon(...)
         button.setIcon(icon);
         icon.setImageObserver(button);
     
    Parameters:
    observer - the image observer
  • setImageObserver

    public void setImageObserver​(ImageObserver observer)
    Sets the image observer for the image. Set this property if the ImageIcon contains an animated GIF, so the observer is notified to update its display. For example:
         icon = new ImageIcon(...)
         button.setIcon(icon);
         icon.setImageObserver(button);
     
    Parameters:
    observer - the image observer

method:getImageObserver() [CHANGED]

  • getImageObserver

    public ImageObserver getImageObserver getImageObserver​()
    Returns the image observer for the image.
    Returns:
    the image observer, which may be null
  • getImageObserver

    public ImageObserver getImageObserver()
    Returns the image observer for the image.
    Returns:
    the image observer, which may be null
  • getImageObserver

    public ImageObserver getImageObserver​()
    Returns the image observer for the image.
    Returns:
    the image observer, which may be null

method:toString() [CHANGED]

  • toString

    public String toString toString​()
    Returns a string representation of this image.
    Overrides:
    toString in class Object
    Returns:
    a string representing this image
  • toString

    public String toString()
    Returns a string representation of this image.
    Overrides:
    toString in class Object
    Returns:
    a string representing this image
  • toString

    public String toString​()
    Returns a string representation of this image.
    Overrides:
    toString in class Object
    Returns:
    a string representing this image

method:getAccessibleContext() [CHANGED]

  • getAccessibleContext

    @BeanProperty(expert=true,
                  description="The AccessibleContext associated with this ImageIcon.")
    public AccessibleContext getAccessibleContext getAccessibleContext​()
    Gets the AccessibleContext associated with this ImageIcon. For image icons, the AccessibleContext takes the form of an AccessibleImageIcon. A new AccessibleImageIcon instance is created if necessary.
    Specified by:
    getAccessibleContext in interface Accessible
    Returns:
    an AccessibleImageIcon that serves as the AccessibleContext of this ImageIcon
    Since:
    1.3
  • getAccessibleContext

    public AccessibleContext getAccessibleContext()
    Gets the AccessibleContext associated with this ImageIcon. For image icons, the AccessibleContext takes the form of an AccessibleImageIcon. A new AccessibleImageIcon instance is created if necessary.
    Specified by:
    getAccessibleContext in interface Accessible
    Returns:
    an AccessibleImageIcon that serves as the AccessibleContext of this ImageIcon
    Since:
    1.3
  • getAccessibleContext

    @BeanProperty(expert=true,
                  description="The AccessibleContext associated with this ImageIcon.")
    public AccessibleContext getAccessibleContext​()
    Gets the AccessibleContext associated with this ImageIcon. For image icons, the AccessibleContext takes the form of an AccessibleImageIcon. A new AccessibleImageIcon instance is created if necessary.
    Specified by:
    getAccessibleContext in interface Accessible
    Returns:
    an AccessibleImageIcon that serves as the AccessibleContext of this ImageIcon
    Since:
    1.3

© 2017 Oracle Corporation and/or its affiliates