01: /**
02: * L2FProd.com Common Components 7.3 License.
03: *
04: * Copyright 2005-2007 L2FProd.com
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package com.l2fprod.common.swing.border;
18:
19: import java.awt.Color;
20: import java.awt.Component;
21: import java.awt.Graphics;
22: import java.awt.Insets;
23:
24: import javax.swing.border.Border;
25:
26: /**
27: * FourLineBorder. <br>
28: *
29: */
30: public class FourLineBorder implements Border {
31:
32: private Color top;
33: private Color left;
34: private Color bottom;
35: private Color right;
36:
37: public FourLineBorder(Color top, Color left, Color bottom,
38: Color right) {
39: this .top = top;
40: this .left = left;
41: this .bottom = bottom;
42: this .right = right;
43: }
44:
45: public Insets getBorderInsets(Component c) {
46: return new Insets(top == null ? 0 : 1, left == null ? 0 : 1,
47: bottom == null ? 0 : 1, right == null ? 0 : 1);
48: }
49:
50: public boolean isBorderOpaque() {
51: return true;
52: }
53:
54: public void paintBorder(Component c, Graphics g, int x, int y,
55: int width, int height) {
56: if (bottom != null) {
57: g.setColor(bottom);
58: g
59: .drawLine(x, y + height - 1, x + width - 1, y
60: + height - 1);
61: }
62:
63: if (right != null) {
64: g.setColor(right);
65: g.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
66: }
67:
68: if (top != null) {
69: g.setColor(top);
70: g.drawLine(x, y, x + width - 1, y);
71: }
72:
73: if (left != null) {
74: g.setColor(left);
75: g.drawLine(x, y, x, y + height - 1);
76: }
77: }
78:
79: }
|