// Example 3.8: A colored panel containing a red text // message in a blue rectangle, centered in the panel // Text font is Courier bold 14 package javaapplication4; import javax.swing.*; import java.awt.*; public class ColorPanel extends JPanel{ private boolean haschecker; private Color CheckerColor; private Circle c1, c2; private Circle selectedCircle; // Used to track selected shape private int x, y; // Used to track mouse coordinates ImageIcon image = new ImageIcon("checkerboard.gif"); public ColorPanel(Color backColor) { setBackground(backColor); haschecker = false; c1 = new Circle(200, 100, 25, Color.red); } public void paintComponent(Graphics g){ super.paintComponent(g); int w = getWidth()-10; int h = getHeight()-10; int w2 = getWidth() / 2; int h2 = getHeight() / 2; w2 = w2 - 1; h2 = h2 - 1; g.drawImage(image.getImage(),0,0,getWidth(),getHeight(),this); c1.fill(g); } }