CircularProgressBarUI is a
javax.swing.plaf.basic.BasicProgressBarUI
that displays the progress of a JProgressBar
as an arc than starts at the top of a circle and progresses clockwise.Simply call:
progressBar.setUI(new CircularProgressBarUI());
And then you can add any number of additional properties, such as:
progressBar.putClientProperty(CircularProgressBarUI.PROPERTY_STROKE_WIDTH, 4); progressBar.putClientProperty(CircularProgressBarUI.PROPERTY_PULSE_COMPLETION_ACTIVE, true); progressBar.putClientProperty(CircularProgressBarUI.PROPERTY_SPARK_ACTIVE, true); progressBar.putClientProperty(CircularProgressBarUI.PROPERTY_ACCELERATE, true); progressBar.putClientProperty(CircularProgressBarUI.PROPERTY_TRANSITION, true);
This is relatively straight-forward ProgressBarUI
. It includes support for JProgressBar
methods like getPercentComplete()
, isIndeterminate()
, isStringPainted()
, getString()
, getForeground()
, getBackground()
and getFont()
. Also it includes these additional features:
Keep in mind that perception can be just as important as raw speed. In order to make a progress bar feel faster to users you can start the progressive animation slower and allow it to move faster as it approaches the end. This way, you give users a rapid sense of completion time.
There are several great articles further discussing the UX implications of progress feedback. For this project I consulted this one, this one, this one and this one. (And I don't know what to make of this one, but it's very interesting!)
The "indeterminate" property of JProgressBars is a little peculiar. In hindsight: it might have been nice if indeterminate progress bars had been an entirely separate JComponent, because a core part of their data model (the BoundedRangeModel) doesn't make sense when they are indeterminate. (The JThrobber mostly addresses this separation.) But to be fair: JProgressBars have been around since J2SE 1.2, and small (mostly circular) throbbers weren't a phenomenon at that time.
Also remember on Mac you can set the client property "JProgressBar.style" to "circular" on a JProgressBar to get the default Mac throbber.