public final class ColorIcon
extends java.lang.Object
implements javax.swing.Icon
ColorIcon is an Icon implementation that is a simple rectangular shape with a black edge rim, and configurable center fill color. The size of the icon must be specified when it is created, but the fill color may be changed later.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_HEIGHT
The default icon height (12) to use if none is specified.
|
static int |
DEFAULT_SIZE
The default icon size (square) to use if none is specified.
|
static int |
DEFAULT_WIDTH
The default icon width (12) to use if none is specified.
|
| Constructor and Description |
|---|
ColorIcon(java.awt.Color color)
Construct a new
ColorIcon with the given fill color and with a default size |
ColorIcon(java.awt.Color color, java.awt.Dimension dimensions)
Construct a new
ColorIcon with the given fill color and dimensions. |
ColorIcon(java.awt.Color color, int width, int height)
Construct a new
ColorIcon with the given fill color and dimensions. |
| Modifier and Type | Method and Description |
|---|---|
java.awt.Color |
getColor()
Fetches the color that is currently used to fill the icon.
|
int |
getIconHeight()
Returns the icon's height.
|
int |
getIconWidth()
Returns the icon's width.
|
void |
paintIcon(java.awt.Component component, java.awt.Graphics graphics, int x, int y)
Draw the icon at the specified location.
|
void |
setColor(java.awt.Color color)
Changes the color that is used to fill the icon.
|
void |
setSize(int width, int height)
Changes the size of the icon.
|
public static final int DEFAULT_SIZE
public static final int DEFAULT_WIDTH
public static final int DEFAULT_HEIGHT
public ColorIcon(java.awt.Color color)
ColorIcon with the given fill color and with a default sizecolor - the fill color to use
public ColorIcon(java.awt.Color color,
int width,
int height)
ColorIcon with the given fill color and dimensions.color - the fill color to usewidth - the width to useheight - the height to use
public ColorIcon(java.awt.Color color,
java.awt.Dimension dimensions)
ColorIcon with the given fill color and dimensions.color - the fill color to usedimension - the width and height dimension to usepublic java.awt.Color getColor()
public void setColor(java.awt.Color color)
color - the new color to use
public void setSize(int width,
int height)
width - the width to useheight - the height to use
public void paintIcon(java.awt.Component component,
java.awt.Graphics graphics,
int x,
int y)
paintIcon in interface javax.swing.Iconpublic int getIconWidth()
getIconWidth in interface javax.swing.Iconpublic int getIconHeight()
getIconHeight in interface javax.swing.Icon