1

I am using NetBeans IDE 8.0.2 and I am trying to change the color of the JProgressBar from the default orange as shown below:

enter image description here

I have tried changing the foreground and background in the properties but the result does nothing except change the color of the text inside the bar, but keeps the color of the bar itself orange.

When I try to manually code the JProgressBar it has more of a 2D appearance as shown below:

enter image description here

How can I change the color of the JProgressBar but also keep the 3D textured style of the default JProgressBar or is not possible?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Osiris93
  • 296
  • 2
  • 18

1 Answers1

0
//this changes color
pb.setForeground(new Color(r,g,b)); 

//this changes textcolor
pb.setUI(new BasicProgressBarUI() {
                protected Color getSelectionBackground() { return Color.black; }
                protected Color getSelectionForeground() { return Color.white; }
            });

I've tested it in metal look and feel and with nimbus

pb is a JProgressBar object.

Varejator
  • 17
  • 7