package bluej.utility;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.Icon;
| Return a filled oval as an Icon
|
| @author Andrew Patterson
|
public class OvalIcon
implements Icon{
private Color color;
private static OvalIcon redIcon;
private static OvalIcon blankIcon;
public static OvalIcon getRedOvalIcon()
{
if (redIcon == null)
redIcon = new OvalIcon(Color.red);
return redIcon;
}
public static OvalIcon getBlankOvalIcon()
{
if (blankIcon == null)
blankIcon = new OvalIcon(null);
return blankIcon;
}
public OvalIcon(Color c)
{
color = c;
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y)
{
if (color != null) {
int width = getIconWidth();
int height = getIconHeight();
g.setColor (color);
g.fillOval (x, y, width, height);
}
}
@Override
public int getIconWidth()
{
return 10;
}
@Override
public int getIconHeight()
{
return 10;
}
}
top,
use,
map,
class OvalIcon
. getRedOvalIcon
. getBlankOvalIcon
. OvalIcon
. paintIcon
. getIconWidth
. getIconHeight
70 neLoCode
+ 2 LoComm