dsto.dfc.swing.icons
Class ResourceImageIcon

java.lang.Object
  extended by javax.swing.ImageIcon
      extended by dsto.dfc.swing.icons.ResourceImageIcon
All Implemented Interfaces:
ImageObserver, Serializable, Accessible, Icon

public class ResourceImageIcon
extends ImageIcon
implements Icon, Serializable, ImageObserver

An icon that is loaded from a resource. The icon image is lazy loaded to speed up application initialization. Unfortunately the Swing designers have implemented auto-greying of icons only for ImageIcon's (by hardcoding calls to ImageIcon.getImage(): see AbstractButton for an example), so this class has to extend ImageIcon and override all its methods for icon disabling to work. If Sun ever fix this, the 'extends ImageIcon' may be removed.

Version:
$Revision$
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.ImageIcon
ImageIcon.AccessibleImageIcon
 
Field Summary
protected  boolean failedToLoadImage
           
protected  Image image
           
protected  int imageHeight
           
protected  int imageWidth
           
protected  String resourceName
           
 
Fields inherited from class javax.swing.ImageIcon
component, tracker
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ResourceImageIcon(String resourceName)
           
 
Method Summary
 int getIconHeight()
           
 int getIconWidth()
           
 Image getImage()
           
 int getImageLoadStatus()
           
 boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)
           
 void paintIcon(Component c, Graphics g, int x, int y)
           
 void setImage(Image image)
           
 
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getImageObserver, loadImage, setDescription, setImageObserver, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resourceName

protected String resourceName

image

protected transient Image image

imageWidth

protected transient int imageWidth

imageHeight

protected transient int imageHeight

failedToLoadImage

protected transient boolean failedToLoadImage
Constructor Detail

ResourceImageIcon

public ResourceImageIcon(String resourceName)
Method Detail

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon
Overrides:
paintIcon in class ImageIcon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface Icon
Overrides:
getIconWidth in class ImageIcon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface Icon
Overrides:
getIconHeight in class ImageIcon

imageUpdate

public boolean imageUpdate(Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Specified by:
imageUpdate in interface ImageObserver

getImageLoadStatus

public int getImageLoadStatus()
Overrides:
getImageLoadStatus in class ImageIcon

getImage

public Image getImage()
Overrides:
getImage in class ImageIcon

setImage

public void setImage(Image image)
Overrides:
setImage in class ImageIcon


Copyright © 2008 Commonwealth of Australia