01: package abbot.editor.widgets;
02:
03: import java.awt.*;
04: import javax.swing.JComponent;
05:
06: /** Provides a persistent border around a component, drawn <i>after</i> the
07: component itself is drawn.
08: */
09: public class Highlighter extends AbstractComponentDecorator {
10: private static final float WIDTH = 2;
11: private static final Color BASE = Color.red;
12: private static final Color COLOR = new Color(BASE.getRed(), BASE
13: .getGreen(), BASE.getBlue(), 64);
14:
15: public Highlighter(JComponent c) {
16: super (c);
17: }
18:
19: public void paint(Graphics graphics) {
20: Component c = getComponent();
21: Graphics2D g = (Graphics2D) graphics;
22: g.setColor(COLOR);
23: g.setStroke(new BasicStroke(WIDTH));
24: g.drawRect(Math.round(0 + WIDTH / 2),
25: Math.round(0 + WIDTH / 2), Math.round(c.getWidth()
26: - WIDTH), Math.round(c.getHeight() - WIDTH));
27: g.fillRect(Math.round(0 + WIDTH / 2),
28: Math.round(0 + WIDTH / 2), Math.round(c.getWidth()
29: - WIDTH), Math.round(c.getHeight() - WIDTH));
30: }
31: }
|