Interface Painter
- All Known Implementing Classes:
BackgroundPainter, GlassTutorial, PainterChain, Timeline
public interface Painter
Painter can be used to draw on components backgrounds.
The use of this interface allows reuse of a background Painter for various
components.
A simple example of a background painter is shown here to draw a circle background:
Component cmp = new Label("Round Background");
Painter p = new Painter() {
public void paint(Graphics g, Rectangle rect) {
boolean antiAliased = g.isAntiAliased();
g.setAntiAliased(true);
try {
int r = Math.min(rect.getWidth(), rect.getHeight()) / 2;
int x = rect.getX() + rect.getWidth() / 2 - r;
int y = rect.getY() + rect.getHeight() / 2 - r;
g.setColor(0x3f51b5);
g.fillArc(x, y, r * 2, r * 2, 0, 360);
} finally {
g.setAntiAliased(antiAliased);
}
}
};
cmp.getStyle().setBgPainter(p);
-
Method Summary
-
Method Details
-
paint
-