Here you can find the source of drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height, final Color main, final Color progress, final int alpha, final int percentage)
public static void drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height, final Color main, final Color progress, final int alpha, final int percentage)
//package com.java2s; //License from project: Open Source License import java.awt.*; public class Main { public static void drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height, final Color main, final Color progress, final int alpha, final int percentage) { g.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); final GradientPaint base = new GradientPaint(x, y, new Color(200, 200, 200, alpha), x, y + height, main); final GradientPaint overlay = new GradientPaint(x, y, new Color(200, 200, 200, alpha), x, y + height, progress);/*from www . j a va 2 s . c om*/ if (height > width) { g.setPaint(base); g.fillRect(x, y, width, height); g.setPaint(overlay); g.fillRect(x, y + (height - (int) (height * (percentage / 100.0D))), width, (int) (height * (percentage / 100.0D))); } else { g.setPaint(base); g.fillRect(x, y, width, height); g.setPaint(overlay); g.fillRect(x, y, (int) (width * (percentage / 100.0D)), height); } g.setColor(Color.BLACK); g.drawRect(x, y, width, height); } }