BamSquid BamSquid - 17 days ago 5
Java Question

Java Swing: Having Multiple Colors in One JProgressBar

My boss has put me in charge of building a production dashboard to track the efficiency of the workers on a production line. He wants a progress bar to fill up in relation to the time and change colors if the worker is running on time or if they're behind, etc. I need to know if you can have multiple colors for one JProgressBar that changes as the bar fills up to show those changes. I'm referring to something like this.

Is this even possible? If not, what's my best course of action to go about doing this? I've thought about putting multiple JProgressBars together and doing some calculations to find out which section needs to be which color, unless there's a better way to go about it.

Answer

Looking at the link I posted above, you might be able to create multiple progressbars, setting the width of them to something predetermined (length of a task), placing them side-by-side, then setting those colors for each piece individually. Looking around I don't see anything for setting colors to from n to m to a certain value.

Comments