buoy.xml
Class IconResource

java.lang.Object
  extended by javax.swing.ImageIcon
      extended by buoy.xml.IconResource
All Implemented Interfaces:
java.io.Serializable, javax.accessibility.Accessible, javax.swing.Icon

public class IconResource
extends javax.swing.ImageIcon

This is a subclass of ImageIcon which loads the image from the classpath by calling ClassLoader.getResource(). The main value of this class is that, unlike standard ImageIcons, it can be successfully serialized as XML by WidgetEncoder. Because the image is specified by a relative path, it will be found when the XML is decoded, regardless of where the application is stored on the computer.

Author:
Peter Eastman
See Also:
Serialized Form

Constructor Summary
IconResource(java.lang.String resourceName)
          Create an IconResource by loading an image file out of the classpath.
IconResource(java.lang.String resourceName, java.lang.ClassLoader classloader)
          Create an IconResource by loading an image file out of the classpath.
IconResource(java.lang.String resourceName, java.lang.String description)
          Create an IconResource by loading an image file out of the classpath.
 
Method Summary
 java.lang.String getResourceName()
          Get the icon's resource name.
 
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getIconHeight, getIconWidth, getImage, getImageLoadStatus, getImageObserver, paintIcon, setDescription, setImage, setImageObserver, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IconResource

public IconResource(java.lang.String resourceName)
Create an IconResource by loading an image file out of the classpath.

Parameters:
resourceName - the name of the resource to load (by passing it to ClassLoader.getResource())

IconResource

public IconResource(java.lang.String resourceName,
                    java.lang.String description)
Create an IconResource by loading an image file out of the classpath.

Parameters:
resourceName - the name of the resource to load (by passing it to Class.getResource())
description - a brief description of the image

IconResource

public IconResource(java.lang.String resourceName,
                    java.lang.ClassLoader classloader)
Create an IconResource by loading an image file out of the classpath. This constructor allows you to specify what ClassLoader should be used to load the resource. This is primarily useful in UI builder applications, where the image should be loaded from the classpath of the application being edited, not the classpath of the UI builder application itself.

Parameters:
resourceName - the name of the resource to load (by passing it to ClassLoader.getResource())
classloader - the ClassLoader with which to load the resource
Method Detail

getResourceName

public java.lang.String getResourceName()
Get the icon's resource name.



Written by Peter Eastman.