void (Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D)g.create(); try { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); Rectangle r = new Rectangle(progressBar.getSize()); if (c.isOpaque()) { g2.setColor(c.getParent().getBackground()); g2.fill(r); } Insets i = progressBar.getInsets(); JBInsets.removeFrom(r, i); int orientation = progressBar.getOrientation(); // Use foreground color as a reference, don't use it directly. This is done for compatibility reason. // Colors are hardcoded in UI delegates by design. If more colors are needed contact designers. Color startColor, endColor; Color foreground = progressBar.getForeground(); if (foreground == ColorProgressBar.RED) { startColor = FAILED_COLOR; endColor = FAILED_END_COLOR; } else if (foreground == ColorProgressBar.GREEN) { startColor = PASSED_COLOR; endColor = PASSED_END_COLOR; } else if (foreground == ColorProgressBar.YELLOW) { startColor = WARNING_COLOR; endColor = WARNING_END_COLOR; } else { startColor = getStartColor(c); endColor = getEndColor(c); } int pHeight = progressBar.getPreferredSize().height; int pWidth = progressBar.getPreferredSize().width; int yOffset = r.y + (r.height - pHeight) / 2; int xOffset = r.x + (r.width - pWidth) / 2; if (isSimplified()) { Color[] ca = {startColor, endColor}; int idx = 0; int delta = JBUIScale.scale(10); if (orientation == SwingConstants.HORIZONTAL) { for (float offset = r.x; offset - r.x < r.width; offset += delta) { g2.setPaint(ca[(getAnimationIndex() + idx++) % 2]); g2.fill(new Rectangle2D.Float(offset, yOffset, delta, pHeight)); } } else { for (float offset = r.y; offset - r.y < r.height; offset += delta) { g2.setPaint(ca[(getAnimationIndex() + idx++) % 2]); g2.fill(new Rectangle2D.Float(xOffset, offset, delta, pWidth)); } } } else { Shape shape; int step = JBUIScale.scale(6); if (orientation == SwingConstants.HORIZONTAL) { shape = getShapedRect(r.x, yOffset, r.width, pHeight, pHeight); yOffset = r.y + pHeight / 2; g2.setPaint(new GradientPaint(r.x + getAnimationIndex() * step * 2, yOffset, startColor, r.x + getFrameCount() * step + getAnimationIndex() * step * 2, yOffset, endColor, true)); } else { shape = getShapedRect(xOffset, r.y, pWidth, r.height, pWidth); xOffset = r.x + pWidth / 2; g2.setPaint(new GradientPaint(xOffset, r.y + getAnimationIndex() * step * 2, startColor, xOffset, r.y + getFrameCount() * step + getAnimationIndex() * step * 2, endColor, true)); } g2.fill(shape); } // Paint text if (progressBar.isStringPainted()) { if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) { paintString((Graphics2D)g, i.left, i.top, r.width, r.height, boxRect.x, boxRect.width); } else { paintString((Graphics2D)g, i.left, i.top, r.width, r.height, boxRect.y, boxRect.height); } } } finally { g2.dispose(); } }