import javax.swing.Icon;
import java.awt.*;

        // A square icon.
class SquareIcon implements Icon {
    public static final int defaultWidth = 10;
    public static final Color defaultColor = Color.blue;

    public SquareIcon(){
        this(defaultWidth,defaultColor);
    }

    public SquareIcon(int w){
        this(w,defaultColor);
    }

    public SquareIcon(Color c){
        this(defaultWidth,c);
    }

    public SquareIcon(int w,Color c){
        if(w <= 0){
            w = defaultWidth;
        }
        if(c == null){
            c = defaultColor;
        }
        width = w;
        color = c;
    }

        // The Icon interface.
    public int getIconHeight(){
        return width;
    }

    public int getIconWidth(){
        return width;
    }

    public void paintIcon(Component c, Graphics g, int x, int y){
        g.setColor(color);
        g.fillRect(x,y,width,width);
    }

    public Color getColor(){
        return color;
    }

    private final int width;
    private final Color color;
}
