|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.JavaBean
org.jdesktop.swingx.painter.AbstractPainter
org.jdesktop.swingx.painter.CheckerboardPainter
public class CheckerboardPainter
A Painter implementation that paints a checkerboard pattern. The light and dark colors (Paint instances) are configurable, as are the size of the squares (squareLength).
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.setSquareLength(32);
panel.seBackgroundPainter(p);
Note that in this example, the "32" in the GradientPaint matches the "32" set for the squareLength. 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.
Constructor Summary | |
---|---|
CheckerboardPainter()
Create a new CheckerboardPainter. |
|
CheckerboardPainter(Paint darkPaint,
Paint lightPaint)
Create a new CheckerboardPainter with the specified light and dark paints. |
|
CheckerboardPainter(Paint darkPaint,
Paint lightPaint,
int length)
Create a new CheckerboardPainter with the specified light and dark paints and the specified square size. |
Method Summary | |
---|---|
Paint |
getDarkPaint()
|
Paint |
getLightPaint()
|
int |
getSquareLength()
|
void |
paintBackground(Graphics2D g,
JComponent component)
Subclasses should implement this method and perform custom painting operations here. |
void |
setDarkPaint(Paint color)
Specifies the paint to use for dark tiles. |
void |
setLightPaint(Paint color)
Specifies the paint to use for light tiles. |
void |
setSquareLength(int length)
Specifies the length of the squares. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CheckerboardPainter()
public CheckerboardPainter(Paint darkPaint, Paint lightPaint)
darkPaint
- the paint used to draw the dark squareslightPaint
- the paint used to draw the light squarespublic CheckerboardPainter(Paint darkPaint, Paint lightPaint, int length)
darkPaint
- the paint used to draw the dark squareslightPaint
- the paint used to draw the light squareslength
- the length of the checker board squaresMethod Detail |
---|
public void setSquareLength(int length)
length
- the length of one side of a square tile. Must be > 0.public int getSquareLength()
public void setDarkPaint(Paint color)
color
- the Paint to use for painting the "dark" tiles. May be null.public Paint getDarkPaint()
public void setLightPaint(Paint color)
color
- the Paint to use for painting the "light" tiles. May be null.public Paint getLightPaint()
public void paintBackground(Graphics2D g, JComponent component)
AbstractPainter
paintBackground
in class AbstractPainter
g
- The Graphics2D object in which to paintcomponent
- The JComponent that the Painter is delegate for.
|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |