Class ColorIcon

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, javax.swing.Icon

    public class ColorIcon
    extends ModelSerialCloneable
    implements javax.swing.Icon
    This is an icon which is a block of color with bounds specified in the constructor. It is from Graphic Java Mastering the JFC Volume II: Swing, by David Geary, published by Sun Microsystems Press 1999, page 1085.
    Version:
    0.1 Aug 1, 1999
    Author:
    David Geary
    See Also:
    ColorRenderer, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Color color
      DOCUMENT ME!
      static java.awt.Color FOREGROUND  
      private int h
      DOCUMENT ME!
      static java.awt.Color TRANSPARENT  
      private int w
      DOCUMENT ME!
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorIcon()
      Constructor Makes a color icon with the default color of gray and default width and height values of 50 and 15, respectively.
      ColorIcon​(java.awt.Color color, int w, int h)
      Constructor Makes a color icon with the specified color, width, and height.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.Color getColor()
      getColor - gets the color of the icon.
      int getIconHeight()
      getIconHeight - gets the height of the icon.
      int getIconWidth()
      getIconWidth - gets the width of the icon.
      void paintIcon​(java.awt.Component c, java.awt.Graphics g, int x, int y)
      paintIcon - paints the icon with a balck border.
      void setColor​(java.awt.Color color)
      setColor - sets the color of the icon.
      void setIconHeight​(int h)
      setIconHeight - sets the height of the icon.
      void setIconWidth​(int w)
      setIconWidth - sets the width of the icon.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TRANSPARENT

        public static final java.awt.Color TRANSPARENT
      • FOREGROUND

        public static final java.awt.Color FOREGROUND
      • color

        private java.awt.Color color
        DOCUMENT ME!
      • w

        private int w
        DOCUMENT ME!
      • h

        private int h
        DOCUMENT ME!
    • Constructor Detail

      • ColorIcon

        public ColorIcon()
        Constructor Makes a color icon with the default color of gray and default width and height values of 50 and 15, respectively.
      • ColorIcon

        public ColorIcon​(java.awt.Color color,
                         int w,
                         int h)
        Constructor Makes a color icon with the specified color, width, and height.
        Parameters:
        color - color to set the icon to
        w - width to set the icon to
        h - height to set the icon to
    • Method Detail

      • getColor

        public java.awt.Color getColor()
        getColor - gets the color of the icon.
        Returns:
        color of the icon
      • getIconHeight

        public int getIconHeight()
        getIconHeight - gets the height of the icon.
        Specified by:
        getIconHeight in interface javax.swing.Icon
        Returns:
        height of the icon
      • getIconWidth

        public int getIconWidth()
        getIconWidth - gets the width of the icon.
        Specified by:
        getIconWidth in interface javax.swing.Icon
        Returns:
        width of the icon
      • paintIcon

        public void paintIcon​(java.awt.Component c,
                              java.awt.Graphics g,
                              int x,
                              int y)
        paintIcon - paints the icon with a balck border.
        Specified by:
        paintIcon in interface javax.swing.Icon
        Parameters:
        c - component to paint
        g - graphics to paint in
        x - beginning x-coordinate
        y - beginning y-coordinate
      • setColor

        public void setColor​(java.awt.Color color)
        setColor - sets the color of the icon.
        Parameters:
        color - color of the icon
      • setIconHeight

        public void setIconHeight​(int h)
        setIconHeight - sets the height of the icon.
        Parameters:
        h - height of the icon
      • setIconWidth

        public void setIconWidth​(int w)
        setIconWidth - sets the width of the icon.
        Parameters:
        w - width of the icon