FilledRectExample
Retired DISLab
FilledRectExample.java
import acm.program.*; import java.awt.*; public class FilledRectExample extends GraphicsProgram { public void run() { double width = getWidth(); double height = getHeight(); double stripe = width / 3; add(new FilledRect(0, 0, stripe, height, Color.BLUE)); add(new FilledRect(stripe, 0, stripe, height, Color.WHITE)); add(new FilledRect(2 * stripe, 0, stripe, height, Color.RED)); } private static final long serialVersionUID = 1; }
FilledRect.java
import acm.graphics.*; import java.awt.*; public class FilledRect extends GRect { public FilledRect(double x, double y, double width, double height) { super(x, y, width, height); setFilled(true); } public FilledRect(double x, double y, double width, double height, Color color) { this(x, y, width, height); setColor(color); } }