void (Graphics g) { // Paint to an image without alpha to preserve fonts subpixel antialiasing BufferedImage image = ImageUtil.createImage(g, getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);//new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); useSafely(image.createGraphics(), imageGraphics -> { //noinspection UseJBColor imageGraphics.setPaint(new Color(myFillColor.getRGB())); // create a copy to remove alpha imageGraphics.fillRect(0, 0, getWidth(), getHeight()); super.paintChildren(imageGraphics); }); Graphics2D g2d = (Graphics2D)g.create(); try { if (JreHiDpiUtil.isJreHiDPI(g2d)) { float s = 1 / JBUIScale.sysScale(g2d); g2d.scale(s, s); } StartupUiUtil.drawImage(g2d, makeColorTransparent(image, myFillColor), 0, 0, null); } finally { g2d.dispose(); } }