Java Swing show progress in pie form

I want to show a progress in pie format. Can anyone help? I have the data to show, but how to show it in this format. Something like progress shown in Google Chrome when we download files.


Based on the links provided by @trashgod, here is one way you can achieve a "Pie" effect. This only handles the indeterminate progress bar, but it would be very easy to add the "determinate" behaviour.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.plaf.basic.BasicProgressBarUI;

/** @see */
public class ProgressBarUITest extends JPanel {

    public ProgressBarUITest() {
        super(new BorderLayout());
        JProgressBar jpb = new JProgressBar();
        jpb.setUI(new MyProgressUI());

    private static class MyProgressUI extends BasicProgressBarUI {

        private static final int ARC_EXTENT = 25;

        protected void installDefaults() {

        protected void paintIndeterminate(Graphics g, JComponent c) {
            int angle = (int) (90 - 360.0 * getAnimationIndex() / getFrameCount());
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            int size = Math.min(c.getWidth(), c.getHeight());
            g2d.fillArc((c.getWidth() - size) / 2, (c.getHeight() - size) / 2, size, size, angle - ARC_EXTENT, ARC_EXTENT);

        protected Rectangle getBox(Rectangle r) {
            if (r != null) {
                return r;
            return progressBar.getBounds();

        public Dimension getPreferredSize(JComponent c) {
            return new Dimension(100, 100);

    private void display() {
        JFrame f = new JFrame("ProgressBarUITest");

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ProgressBarUITest().display();

Need Your Help

how to describe this regular expression in English

regex formal-languages

I am trying to describe regular expression in English here,

Same old story - VS vs GCC 4.6.1

c++ visual-studio-2010 gcc4

The code below compiles fine with VS2010 but fails to compile with gcc 4.6.1:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.