1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.guilayer.swing.extensions;
17
18 import java.awt.Color;
19 import java.awt.Component;
20 import java.awt.Graphics;
21
22 import javax.swing.border.LineBorder;
23
24
25
26
27
28
29 public class NyxLineBorder extends LineBorder {
30
31
32
33
34 public NyxLineBorder(Color color) {
35 super(color);
36 }
37
38
39
40
41
42 public NyxLineBorder(Color color, int thickness) {
43 super(color, thickness);
44 }
45
46
47
48
49
50
51 public NyxLineBorder(Color color, int thickness, boolean roundedCorners) {
52 super(color, thickness, roundedCorners);
53 }
54
55
56
57
58
59
60
61
62
63
64
65 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
66 Color oldColor = g.getColor();
67 int i;
68
69
70 g.setColor(lineColor);
71 for (i = 0; i < thickness; i++) {
72 if (!roundedCorners) {
73 System.out.println("Without rounded corners");
74 System.out.println("x+i = " + (x + i));
75 System.out.println("y+i = " + (y + i));
76 System.out.println("width-i-i-1 = " + (width - i - i - 1));
77 System.out.println("height-i-i-1 = " + (height - i - i - 1));
78 g.drawRect(x + i, y + i, width - i - i - 1, height - i - i - 1);
79 } else {
80 g.drawRoundRect(x + i, y + i, width - i - i - 1, height - i - i - 1, thickness, thickness);
81 }
82 }
83 g.setColor(oldColor);
84 }
85
86
87 }