Hi
I'm trying to implement a Decorator that will add a red border around
a component. I've got the following, which seems to work sometimes,
but not always.
What am I doing wrong?
Thanks, Noel.
/** draws a red border around a component */
private final class OutlineDecorator implements Decorator {
private Component component = null;
private Graphics2D graphics = null;
public Graphics2D prepare(Component component, Graphics2D
graphics) {
this.component = component;
this.graphics = graphics;
return graphics;
}
public void update() {
graphics.setColor(Color.RED);
graphics.drawRect(-1, -1, component.getWidth() + 1,
component
.getHeight() + 1);
}
public Bounds getBounds(Component component) {
return new Bounds(-1, -1, component.getWidth() + 1,
component
.getHeight() + 1);
}
public AffineTransform getTransform(Component component) {
return new AffineTransform();
}
}