jas.util
Class JASIcon
java.lang.Object
|
+--javax.swing.ImageIcon
|
+--jas.util.JASIcon
- All Implemented Interfaces:
- javax.accessibility.Accessible, javax.swing.Icon, java.io.Serializable
- Direct Known Subclasses:
- SwingStudioIcon
- public class JASIcon
- extends javax.swing.ImageIcon
A convenience class for creating small icons where the source file is stored in the
CLASSPATH of the application, typically in the same JAR file as the class creating the
image
- See Also:
- Serialized Form
Inner classes inherited from class javax.swing.ImageIcon |
javax.swing.ImageIcon.AccessibleImageIcon |
Fields inherited from class javax.swing.ImageIcon |
component, tracker |
Constructor Summary |
JASIcon(java.lang.Class c)
Create a JASIcon without specifing the source |
JASIcon(java.lang.Class c,
java.lang.String file)
Create a JASIcon from the CLASSPATH. |
JASIcon(java.lang.Object obj,
java.lang.String file)
Create a JASIcon from the CLASSPATH. |
Method Summary |
static JASIcon |
create(java.lang.Class c,
java.lang.String file)
Create a JASIcon but do not throw an exception if the source cannot be found
(just displays a "broken" icon instead)
//TODO: Should create return a cached version of the JASIcon, instead of a cached
// version of the image with a new JASIcon object? |
static JASIcon |
create(java.lang.Object obj,
java.lang.String file)
Create a JASIcon but do not throw an exception if the source cannot be found
(just displays a "broken" icon instead) |
boolean |
equals(java.lang.Object in)
Override Objects equals method. |
int |
hashCode()
Override Objects hashCode method |
void |
setImage(java.lang.String file)
This method sets the image of the JASIcon to be that referenced by file. |
Methods inherited from class javax.swing.ImageIcon |
getAccessibleContext, getDescription, getIconHeight, getIconWidth, getImage, getImageLoadStatus, getImageObserver, loadImage, paintIcon, setDescription, setImage, setImageObserver, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
JASIcon
public JASIcon(java.lang.Object obj,
java.lang.String file)
throws ImageException
- Create a JASIcon from the CLASSPATH.
- Parameters:
obj
- The object used as the root of the file pathfile
- The path to the image source file, relative to obj- Throws:
ImageException
- Thrown if the image source file can not be found- See Also:
create(Object obj, String file)
JASIcon
public JASIcon(java.lang.Class c,
java.lang.String file)
throws ImageException
- Create a JASIcon from the CLASSPATH.
- Parameters:
c
- The class used as the root of the file pathfile
- The path to the image source file, relative to the root class- Throws:
ImageException
- Thrown if the image source file can not be found- See Also:
create(Object c, String file)
JASIcon
public JASIcon(java.lang.Class c)
- Create a JASIcon without specifing the source
- Parameters:
Class
- c The class used as the root of the file path when setImage is called- See Also:
setImage(String file)
setImage
public void setImage(java.lang.String file)
- This method sets the image of the JASIcon to be that referenced by file.
The image will display as "broken" if the file can not be found, no exception is thrown
- Parameters:
file
- The path to the image source file, relative to the root class
hashCode
public int hashCode()
- Override Objects hashCode method
- Overrides:
hashCode
in class java.lang.Object
equals
public boolean equals(java.lang.Object in)
- Override Objects equals method. Two images are considered equal if they have the same
class and file.
- Overrides:
equals
in class java.lang.Object
create
public static JASIcon create(java.lang.Object obj,
java.lang.String file)
- Create a JASIcon but do not throw an exception if the source cannot be found
(just displays a "broken" icon instead)
- Parameters:
obj
- The object used as the root of the file pathfile
- The path to the image source file, relative to obj- Returns:
- The resulting JASIcon
create
public static JASIcon create(java.lang.Class c,
java.lang.String file)
- Create a JASIcon but do not throw an exception if the source cannot be found
(just displays a "broken" icon instead)
//TODO: Should create return a cached version of the JASIcon, instead of a cached
// version of the image with a new JASIcon object?
- Parameters:
obj
- The class used as the root of the file pathfile
- The path to the image source file, relative to obj- Returns:
- The resulting JASIcon