A capacity indicator, as its name suggests, provides graphical information about the current state of somethingThe Capacity Indicator was implemented as a
that has a finite capacity, such as storage space or battery charge. There are two styles of capacity indicator,
continuous and discrete. A continuous capacity indicator is a translucent track that is filled with a colored
bar that indicates the current value. For example, Figure 15-61 shows a continuous capacity indicator that
represents how much space has been used (and how much space is left) in the user’s mail account.
BasicProgressBarUI
with the paint()
method overridden. The Paint method figures out the Percentage of the bar and determines the needed color, which will then be painted using 3 different ImageIcons
. Before that, the whole length of the bar is filled with a gradient background. The 3 bounds of the colors can also be specified by setting Client Properties on the JProgressBar
. As Usual, the Source is included with the JAR.All four Images can be found here with the source file. The UI includes a main() method for preview or test purposes so you can see the UI. There are no tick marks yet; but sometime I'll revisit this topic and add the tick marks maybe into this UI or as a seperate JComponent.