ColoredRectpublic class ColoredRect extends DrawableRect This class subclasses DrawableRect and adds colors to the rectangle it draws |
Fields Summary |
---|
protected Color | border | protected Color | fill |
Constructors Summary |
---|
public ColoredRect(int x1, int y1, int x2, int y2, Color border, Color fill)This constructor uses super() to invoke the superclass constructor, and
also does some initialization of its own.
super(x1, y1, x2, y2);
this.border = border;
this.fill = fill;
|
Methods Summary |
---|
public void | draw(java.awt.Graphics g)This method overrides the draw() method of our superclass so that it
can make use of the colors that have been specified.
g.setColor(fill);
g.fillRect(x1, y1, (x2-x1), (y2-y1));
g.setColor(border);
g.drawRect(x1, y1, (x2-x1), (y2-y1));
|
|