Class ImageIconWrapper

  • All Implemented Interfaces:
    java.io.Serializable, javax.accessibility.Accessible, javax.swing.Icon, FileBasedIcon
    Direct Known Subclasses:
    DisabledImageIconWrapper, ScaledImageIconWrapper

    public class ImageIconWrapper
    extends javax.swing.ImageIcon
    implements FileBasedIcon
    ImageIconWrapper provides the ability to instantiate an ImageIcon with delayed loading. In addition to delayed loading it has the added benefit of allowing the use of static initialization of ImageIcons without starting the Swing thread which can cause problems when running headless.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.ImageIcon

        javax.swing.ImageIcon.AccessibleImageIcon
    • Field Summary

      • Fields inherited from class javax.swing.ImageIcon

        component, tracker
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageIconWrapper​(byte[] imageBytes, java.lang.String imageName)
      Construct wrapped ImageIcon based upon specified image byte array (see Toolkit.createImage(byte[]))
      ImageIconWrapper​(java.awt.Image image, java.lang.String imageName)
      Construct wrapped ImageIcon based upon specified image
      ImageIconWrapper​(java.net.URL url)
      Construct wrapped ImageIcon based upon specified resource URL
      ImageIconWrapper​(javax.swing.Icon icon)
      Construct wrapped ImageIcon based upon specified icon which may require transformation into ImageIcon
    • Constructor Detail

      • ImageIconWrapper

        public ImageIconWrapper​(byte[] imageBytes,
                                java.lang.String imageName)
        Construct wrapped ImageIcon based upon specified image byte array (see Toolkit.createImage(byte[]))
        Parameters:
        imageBytes - image bytes
        imageName - image reference name
      • ImageIconWrapper

        public ImageIconWrapper​(java.awt.Image image,
                                java.lang.String imageName)
        Construct wrapped ImageIcon based upon specified image
        Parameters:
        image - icon image
        imageName - image reference name
      • ImageIconWrapper

        public ImageIconWrapper​(javax.swing.Icon icon)
        Construct wrapped ImageIcon based upon specified icon which may require transformation into ImageIcon
        Parameters:
        icon - the icon
      • ImageIconWrapper

        public ImageIconWrapper​(java.net.URL url)
        Construct wrapped ImageIcon based upon specified resource URL
        Parameters:
        url - icon image resource URL
    • Method Detail

      • getFilename

        public java.lang.String getFilename()
        Description copied from interface: FileBasedIcon
        Get the name of the image which in most cases will be the associated data file path.
        Specified by:
        getFilename in interface FileBasedIcon
        Returns:
        icon name/path
      • getImageName

        public java.lang.String getImageName()
        Get icon reference name
        Returns:
        icon name
      • getImage

        public java.awt.Image getImage()
        Overrides:
        getImage in class javax.swing.ImageIcon
      • getAccessibleContext

        public javax.accessibility.AccessibleContext getAccessibleContext()
        Specified by:
        getAccessibleContext in interface javax.accessibility.Accessible
        Overrides:
        getAccessibleContext in class javax.swing.ImageIcon
      • getDescription

        public java.lang.String getDescription()
        Overrides:
        getDescription in class javax.swing.ImageIcon
      • getIconHeight

        public int getIconHeight()
        Specified by:
        getIconHeight in interface javax.swing.Icon
        Overrides:
        getIconHeight in class javax.swing.ImageIcon
      • getIconWidth

        public int getIconWidth()
        Specified by:
        getIconWidth in interface javax.swing.Icon
        Overrides:
        getIconWidth in class javax.swing.ImageIcon
      • getImageLoadStatus

        public int getImageLoadStatus()
        Overrides:
        getImageLoadStatus in class javax.swing.ImageIcon
      • getImageObserver

        public java.awt.image.ImageObserver getImageObserver()
        Overrides:
        getImageObserver in class javax.swing.ImageIcon
      • paintIcon

        public void paintIcon​(java.awt.Component c,
                              java.awt.Graphics g,
                              int x,
                              int y)
        Specified by:
        paintIcon in interface javax.swing.Icon
        Overrides:
        paintIcon in class javax.swing.ImageIcon
      • setDescription

        public void setDescription​(java.lang.String description)
        Overrides:
        setDescription in class javax.swing.ImageIcon
      • setImage

        public void setImage​(java.awt.Image image)
        Overrides:
        setImage in class javax.swing.ImageIcon
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class javax.swing.ImageIcon
      • createIconBaseImage

        protected final java.awt.Image createIconBaseImage()
        Get the base icon image to be transformed in ImageIcon
        Returns:
        the base icon image to be transformed in ImageIcon
      • createImageIcon

        protected javax.swing.ImageIcon createImageIcon()