// Prepare the decorators
DecoratorSequence decorators = component.getDecorators();
int n = decorators.getLength();
for (int i = n - 1; i >= 0; i--) {
Decorator decorator = decorators.get(i);
decoratedGraphics = decorator.prepare(component, decoratedGraphics);
}
// Paint the component
Graphics2D componentGraphics = (Graphics2D)decoratedGraphics.create();
componentGraphics.clipRect(0, 0, componentBounds.width, componentBounds.height);
component.paint(componentGraphics);
componentGraphics.dispose();
// Update the decorators
for (int i = 0; i < n; i++) {
Decorator decorator = decorators.get(i);
decorator.update();
}
}
}
}