我注意到当我用 Color(0,0,0,0) 画一些东西时,它在另一个图像上,显示的颜色是 JFrame 背景,而不是它下面的图像。
帮助我找到解决方案的原因?
谢谢!!
编辑:看圆圈,灰色区域(角)应该是透明的,但不是,相反,它们是 JFrame 的颜色。 替代文字 http://img72.imageshack.us/img72/9657/transparency.png
这是绘制圆圈的代码:
公共无效油漆(最终图形g){ super.paintComponent(g); 最终的 Graphics2D g2 = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (unitImage == null) { unitImage = (BufferedImage) (createImage(30, 30)); final Graphics2D gc = unitImage.createGraphics(); gc.setRenderingHints(rh); gc.setColor(outsideColor); gc.fillOval(0, 0, 直径, 直径); gc.setColor(middleColor); gc.fillOval(直径/6,直径/6,(直径/3)*2,(直径/3)*2); gc.setColor(innerColor); gc.fillOval(直径/3,直径/3,直径/3,直径/3); } g2.drawImage(unitImage, null, 0, 0);
一直在玩 Alphacomposites,我认为这不是解决方案。所以我添加了所有这些我相信的新信息,这将帮助你们给我另一个提示。