A Painter implementation that paints a checkerboard pattern. The light and dark colors (Paint instances) are configurable, as are the size of the squares (squareSize).
To configure a checkerboard pattern that used a gradient for the dark tiles and Color.WHITE for the light tiles, you could:
GradientPaint gp = new GradientPaint( new Point2D.Double(0, 0), Color.BLACK, new Point2D.Double(0, 32), Color.GRAY); CheckerboardPainter p = new CheckerboardPainter(); p.setDarkPaint(gp); p.setLightPaint(Color.WHITE); p.setSquareSize(32); panel.seBackgroundPainter(p);
Note that in this example, the "32" in the GradientPaint matches the "32" set for the squareSize. This is necessary because GradientPaints don't readjust themselves for the size of the square. They are fixed and immutable at the time of creation.
@author rbair
|
|