01: /*
02: * SQLeonardo :: java database frontend
03: * Copyright (C) 2004 nickyb@users.sourceforge.net
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * as published by the Free Software Foundation; either version 2
08: * of the License, or (at your option) any later version.
09: *
10: * This program is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU General Public License for more details.
14: *
15: * You should have received a copy of the GNU General Public License
16: * along with this program; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18: *
19: */
20:
21: package nickyb.sqleonardo.common.gui;
22:
23: import java.awt.Color;
24: import java.awt.Component;
25: import java.awt.Graphics;
26: import java.awt.Insets;
27:
28: import javax.swing.border.AbstractBorder;
29:
30: public class CustomLineBorder extends AbstractBorder {
31: protected Insets borderInsets = new Insets(2, 2, 2, 2);
32:
33: protected int thickness = 1;
34: protected Color lineColor = new Color(153, 153, 153, 153);
35:
36: protected boolean left, right, top, bottom;
37:
38: public CustomLineBorder() {
39: this (true, true, true, true);
40: }
41:
42: public CustomLineBorder(boolean top, boolean left, boolean bottom,
43: boolean right) {
44: this .top = top;
45: this .left = left;
46: this .bottom = bottom;
47: this .right = right;
48: }
49:
50: public void paintBorder(Component c, Graphics g, int x, int y,
51: int width, int height) {
52: Color oldColor = g.getColor();
53: g.setColor(lineColor);
54:
55: for (int i = 0; i < thickness; i++) {
56: if (top)
57: g.drawLine(x + i, y + i, width - i - i - 1, y + i);
58:
59: if (bottom)
60: g.drawLine(x + i, y + height - i - i - 1, width - i - i
61: - 1, y + height - i - i - 1);
62:
63: if (left)
64: g.drawLine(x + i, y + i, x + i, y + height - i - i - 1);
65:
66: if (right)
67: g.drawLine(x + width - i - i - 1, y + i, x + width - i
68: - i - 1, y + height - i - i - 1);
69: }
70:
71: g.setColor(oldColor);
72: }
73:
74: public Insets getBorderInsets(Component c) {
75: return borderInsets;
76: }
77: }
|