1 | private Icon createIcon(Color color) {
↵ | | 1 | private Icon createIcon(Color color) {↵
|
2 | int width = 16;
↵ | | 2 | int width = 16;↵
|
3 | int height = 16;
↵ | | 3 | int height = 16;↵
|
4 | BufferedImage image = new BufferedImage(width, height,
↵ | | 4 | BufferedImage image = new BufferedImage(width, height,↵
|
5 | BufferedImage.TYPE_INT_ARGB);↵ | | 5 | BufferedImage.TYPE_INT_ARGB);↵
|
6 |
↵ | | |
|
|
7 | Graphics2D graphics = (Graphics2D) image.getGraphics();
↵ | | 6 | Graphics2D graphics = (Graphics2D) image.getGraphics();↵
|
8 | graphics.setColor(darker(color));
↵ | | 7 | graphics.setColor(darker(color));↵
|
9 | graphics.drawRect(1, 1, width - 3, height - 3);
↵ | | 8 | graphics.drawRect(1, 1, width - 3, height - 3);↵
|
10 | graphics.setColor(color);
↵ | | 9 | graphics.setColor(color);↵
|
11 | graphics.fillRect(2, 2, width - 4, height - 4);
↵ | | 10 | graphics.fillRect(2, 2, width - 4, height - 4);↵
|
12 | graphics.dispose();↵ | | 11 | graphics.dispose();↵
|
13 |
↵ | | |
|
|
14 | return new ImageIcon(image);
↵ | | 12 | return new ImageIcon(image);↵
|
15 | }↵ | | 13 | }↵
|
16 |
↵ | | |
|
| | | 14 | ↵
|
17 | private final static double FACTOR = 0.90;↵ | | 15 | private final static double FACTOR = 0.90;↵
|
18 |
↵ | | |
|
|
19 | private Color darker(Color c) {
↵ | | 16 | private Color darker(Color c) {↵
|
20 | return new Color(Math.max((int) (c.getRed() * FACTOR), 0), Math.max(
↵ | | 17 | return new Color(Math.max((int) (c.getRed() * FACTOR), 0), Math.max(↵
|
21 | (int) (c.getGreen() * FACTOR), 0), Math.max(
↵ | | 18 | (int) (c.getGreen() * FACTOR), 0), Math.max(↵
|
22 | (int) (c.getBlue() * FACTOR), 0)) | | 19 | (int) (c.getBlue() * FACTOR), 0))
|