Jac*_*ck' 1 java icons swing image colors
我需要以编程方式创建ImageIcon一个简单的颜色(比方说蓝色):
所以我开始这样做:
ImageIcon imageIcon = new ImageIcon();
Run Code Online (Sandbox Code Playgroud)
现在我试图ImageIcon用蓝色填充我的。
这应该可以解决问题
BufferedImage image = new BufferedImage(60, 60, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
graphics.setPaint(new Color(0, 0, 128));
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
ImageIcon imageIcon = new ImageIcon(image);
Run Code Online (Sandbox Code Playgroud)