1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.aequo.gui;
14
15 import java.awt.Color;
16 import java.awt.Component;
17 import java.awt.Graphics;
18
19 import javax.swing.border.EmptyBorder;
20
21
22
23
24
25
26 public class LineBorder extends EmptyBorder {
27
28
29 protected Color color = Color.BLACK;
30
31
32
33
34
35
36
37
38 public LineBorder(int top, int left, int bottom, int right) {
39 super(top, left, bottom, right);
40 }
41
42
43
44
45
46
47
48
49
50 public LineBorder(Color color, int top, int left, int bottom, int right) {
51 super(top, left, bottom, right);
52 }
53
54
55
56
57
58 public boolean isBorderOpaque() { return false; }
59
60
61
62
63
64
65
66
67
68
69 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
70 int w = width - 1;
71 int h = height - 1;
72
73 Color oldColor = g.getColor();
74 g.setColor(color);
75
76 g.translate(x, y);
77
78 if (top == 1) {
79 g.drawLine(0, 0, w, 0);
80 } else if (top > 1) {
81 g.fillRect(0, 0, w, top);
82 }
83 if (left == 1) {
84 g.drawLine(0, 0, 0, h);
85 } else if (left > 1) {
86 g.fillRect(0, 0, left, h);
87 }
88
89 if (right == 1) {
90 g.drawLine(w, 0, w, h);
91 } else if (right > 1) {
92 g.fillRect(w - right, 0, w, h);
93 }
94
95 if (bottom == 1) {
96 g.drawLine(0, h, w, h);
97 } else if (bottom > 1) {
98 g.fillRect(0, h - bottom, w, h);
99 }
100 g.translate(-x, -y);
101 g.setColor(oldColor);
102 }
103
104 }