PDA

View Full Version : Java JProgressBar color




NewbieNerd
Sep 6, 2006, 01:35 PM
Anyone know how to change the color of the JProgressBar?



Josh
Sep 6, 2006, 01:57 PM
Before creating the progress bar, add these lines:

UIManager.put("ProgressBar.selectionBackground",Color.BLUE);
UIManager.put("ProgressBar.selectionForeground",Color.WHITE);


Change the colors as needed.

(got this from a google search)

NewbieNerd
Sep 6, 2006, 02:44 PM
Before creating the progress bar, add these lines:

UIManager.put("ProgressBar.selectionBackground",Color.BLUE);
UIManager.put("ProgressBar.selectionForeground",Color.WHITE);


Change the colors as needed.

(got this from a google search)

Yeah, I found that, but it doesn't seem to work for me.

NewbieNerd
Sep 6, 2006, 02:54 PM
Okay, so it can be done if you use a different LookAndFeel ( I tried the Metal one ) instead of the default Aqua, but (a) I don't really want to change from Aqua, and (b) that doesn't allow me to change after creating stuff.

bousozoku
Sep 6, 2006, 02:58 PM
Okay, so it can be done if you use a different LookAndFeel ( I tried the Metal one ) instead of the default Aqua, but (a) I don't really want to change from Aqua, and (b) that doesn't allow me to change after creating stuff.

Aqua is Aqua, you can't change it except for blue and graphite.

You could probably find a look-and-feel that's similar that can be modified and that one might take fewer resources to run.

NewbieNerd
Sep 6, 2006, 04:35 PM
Aqua is Aqua, you can't change it except for blue and graphite.

You could probably find a look-and-feel that's similar that can be modified and that one might take fewer resources to run.

Yeah, makes perfect sense. I had figured the same since I first started trying to figure out how, but my boss thought it would look nice to turn the bar green/yellow/red, and I have very little GUI experience so I couldn't argue.

So obviously part of this is showing the status of something, best represented by the traditional stop light colors. Anyone have a creative way to do it? I'm trying to figure the Graphics2D stuff out to do it that boring way, but I'm interested if anyone has any brighter ideas.