01: /*
02: * EtchedBorderTop.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.components;
13:
14: import java.awt.Color;
15: import java.awt.Component;
16: import java.awt.Graphics;
17: import java.awt.Insets;
18: import javax.swing.border.AbstractBorder;
19:
20: public class EtchedBorderTop extends AbstractBorder {
21: protected Color color;
22:
23: /**
24: * Creates a spacer top border with the specified thickness
25: */
26: public EtchedBorderTop() {
27: }
28:
29: public void paintBorder(Component c, Graphics g, int x, int y,
30: int width, int height) {
31: Color oldColor = g.getColor();
32:
33: Color bg = c.getBackground();
34: Color light = bg.brighter();
35: Color shade = bg.darker();
36:
37: int w = width;
38:
39: g.translate(x, y);
40:
41: g.setColor(shade);
42: g.drawRect(0, 0, w - 1, 0);
43:
44: g.setColor(light);
45: g.drawLine(0, 1, w - 1, 1);
46:
47: g.translate(-x, -y);
48: }
49:
50: public Insets getBorderInsets(Component c) {
51: return new Insets(2, 0, 0, 0);
52: }
53:
54: public Insets getBorderInsets(Component c, Insets insets) {
55: insets.left = insets.right = insets.bottom = 0;
56: insets.top = 2;
57: return insets;
58: }
59:
60: }
|