buoy.xml

Class IconResource


public class IconResource
extends 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

Constructor Summary

IconResource(String resourceName)
Create an IconResource by loading an image file out of the classpath.
IconResource(String resourceName, ClassLoader classloader)
Create an IconResource by loading an image file out of the classpath.
IconResource(String resourceName, String description)
Create an IconResource by loading an image file out of the classpath.

Method Summary

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

Constructor Details

IconResource

public IconResource(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(String resourceName,
                    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

IconResource

public IconResource(String resourceName,
                    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

Method Details

getResourceName

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

Written by Peter Eastman.