Class ColorIcon

java.lang.Object
org.opensourcephysics.display.ColorIcon
All Implemented Interfaces:
Icon

public class ColorIcon extends Object implements Icon
This Icon fills or outlines itself with the color specified in its constructor.
Author:
Douglas Brown
  • Constructor Details

    • ColorIcon

      public ColorIcon(Color color, int width, int height)
      Constructs a ColorIcon.
      Parameters:
      color - color of the icon
      width - width of the icon
      height - height of the icon
    • ColorIcon

      public ColorIcon(Color fillColor, Color outlineColor, int width, int height)
      Constructs an outlined ColorIcon.
      Parameters:
      fillColor - fill color of the icon
      outlineColor - outline color of the icon
      width - width of the icon
      height - height of the icon
  • Method Details

    • setColor

      public void setColor(Color color)
      Sets the color.
      Parameters:
      color - the desired color
    • getIconWidth

      public int getIconWidth()
      Gets the icon width.
      Specified by:
      getIconWidth in interface Icon
      Returns:
      the icon width
    • getIconHeight

      public int getIconHeight()
      Gets the icon height.
      Specified by:
      getIconHeight in interface Icon
      Returns:
      the icon height
    • paintIcon

      public void paintIcon(Component c, Graphics _g, int x, int y)
      Paints the icon.
      Specified by:
      paintIcon in interface Icon
      Parameters:
      c - the component on which it is painted
      _g - the graphics context
      x - the x coordinate of the icon
      y - the y coordinate of the icon