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