Documentation of 'jas2.util.JASIcon' Java class
JASIcon
jas2.util

Class JASIcon

  • All Implemented Interfaces:
    java.io.Serializable, javax.accessibility.Accessible, javax.swing.Icon
    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
    • Constructor Summary

      Constructors 
      Constructor and Description
      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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      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, paintIcon, setDescription, setImage, setImageObserver, toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • 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 path
        file - 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 path
        file - 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)
    • Method Detail

      • 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 path
        file - 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 path
        file - The path to the image source file, relative to obj
        Returns:
        The resulting JASIcon

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.