uk.org.redfelineninja.awt
Class ColorBlockIcon

java.lang.Object
  |
  +--uk.org.redfelineninja.awt.ColorBlockIcon
All Implemented Interfaces:
javax.swing.Icon

public class ColorBlockIcon
extends java.lang.Object
implements javax.swing.Icon

This icon is a single block of colour. This class could be used to provide a coloured button that will call a colour selector.

Author:
Daniel Thompson, Jan 1999

Constructor Summary
ColorBlockIcon()
           
ColorBlockIcon(java.awt.Color c)
           
ColorBlockIcon(java.awt.Color c, java.awt.Dimension s)
           
 
Method Summary
 boolean getAutoSize()
          Detect whether this Icon will automatically resize to its environment.
 java.awt.Color getColor()
           
 int getIconHeight()
          Get the height of the icon.
 int getIconWidth()
          Get the width of the icon.
 java.awt.Dimension getSize()
          Returns the current size of this Icon.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
           
 void setAutoSize(boolean a)
          Set whether this icon should automatically resize to its environment.
 void setColor(java.awt.Color c)
           
 void setSize(java.awt.Dimension s)
          Set the size of the icon.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorBlockIcon

public ColorBlockIcon()

ColorBlockIcon

public ColorBlockIcon(java.awt.Color c)

ColorBlockIcon

public ColorBlockIcon(java.awt.Color c,
                      java.awt.Dimension s)
Method Detail

setAutoSize

public void setAutoSize(boolean a)
Set whether this icon should automatically resize to its environment.


getAutoSize

public boolean getAutoSize()
Detect whether this Icon will automatically resize to its environment.

Returns:
true if the Icon will automatically resize.

setSize

public void setSize(java.awt.Dimension s)
Set the size of the icon. This is ignored if the Icon can automatically resize.


getSize

public java.awt.Dimension getSize()
Returns the current size of this Icon.


getColor

public java.awt.Color getColor()

setColor

public void setColor(java.awt.Color c)

getIconHeight

public int getIconHeight()
Get the height of the icon. If the icon can automatically resize this method will return 10 to prevent problems during screen resize. Otherwise it returns the specified size.

Specified by:
getIconHeight in interface javax.swing.Icon
Returns:
the height of the icon

getIconWidth

public int getIconWidth()
Get the width of the icon. If the icon can automatically resize this method will return 10 to prevent problems during screen resize. Otherwise it returns the specified size.

Specified by:
getIconWidth in interface javax.swing.Icon
Returns:
the width of the icon

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface javax.swing.Icon