import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import javax.swing.JComponent; /** * */ /** * @author barbaralerner * */ public class ColorPanel extends JComponent { private Color mixedColor = Color.BLACK; public void paintComponent (Graphics g) { // Find out how big the panel is. Dimension d = getSize(); // Make the background black by drawing a black rectangle the size of the panel. g.setColor(mixedColor); g.fillRect(0, 0, d.width, d.height); } /** * @param color */ public void setColor(Color color) { mixedColor = color; repaint(); } }