ExtPnlAgk.java
2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package org.emercit.components;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class ExtPnlAgk extends JPanel {
protected int _strokeSize = 1;
protected Color _shadowColor = Color.BLACK;
protected boolean _shadowed = true;
protected boolean _highQuality = true;
protected Dimension _arcs = new Dimension(15, 15);
protected int _shadowGap = 5;
protected int _shadowOffset = 4;
protected int _shadowAlpha = 150;
public Color _backgroundColor = Color.lightGray;
public ExtPnlAgk() {
super();
}
/*
* @Override public void setBackground(Color c) { _backgroundColor = c; }
*/
public void setGreen() {
_backgroundColor = new Color(51, 204, 102);
}
public void setYellow() {
_backgroundColor = new Color(255, 255, 102);
}
public void setRed() {
_backgroundColor = new Color(255, 51, 102);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getWidth();
int height = getHeight();
int shadowGap = this._shadowGap;
Color shadowColorA = new Color(_shadowColor.getRed(),
_shadowColor.getGreen(), _shadowColor.getGreen(), _shadowAlpha);
Graphics2D graphics = (Graphics2D) g;
if (_highQuality) {
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
if (_shadowed) {
graphics.setColor(shadowColorA);
graphics.fillRoundRect(_shadowOffset, _shadowOffset, width
- _strokeSize - _shadowOffset, height - _strokeSize
- _shadowOffset, _arcs.width, _arcs.height);
} else {
_shadowGap = 1;
}
graphics.setColor(_backgroundColor);
graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap,
_arcs.width, _arcs.height);
graphics.setStroke(new BasicStroke(_strokeSize));
graphics.setColor(getForeground());
graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap,
_arcs.width, _arcs.height);
graphics.setStroke(new BasicStroke());
}
}