Class SwingIcon

  • All Implemented Interfaces:
    SwingResource, Icon

    public class SwingIcon
    extends Object
    implements Icon, SwingResource
    Used to specify a Icon. The icon is either loaded from the classpath using new ImageIcon(classLoader.getResource(name)), from the file system using new ImageIcon(name) or from the current look and feel using UIManager.getIcon(name).
    • Constructor Detail

      • SwingIcon

        public SwingIcon​(int type,
                         String name)
        Constructs a icon.
        Parameters:
        type - The icon type (CLASSPATH, FILE or SWING).
        name - The icon name. A resource name (see java.lang.ClassLoader.getResource(String)) if type is CLASSPATH, a file name (see javax.swing.ImageIcon(String)) if type is FILE or a key (see javax.swing.UIManager.getIcon(String)) if type is SWING.
    • Method Detail

      • getName

        public String getName()
        Returns the icon name. A resource name if type is CLASSPATH, a file name if type is FILE or a key if type is SWING.
      • createIcon

        public Icon createIcon​(ClassLoader loader)
        For internal use only.
      • getIconWidth

        public int getIconWidth()
        Specified by:
        getIconWidth in interface Icon
      • getIconHeight

        public int getIconHeight()
        Specified by:
        getIconHeight in interface Icon
      • equals

        public boolean equals​(Object obj)
        Determines whether another object is equal to this object.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Returns the hash code for this object.
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Returns a string representation of the object.
        Overrides:
        toString in class Object