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