-4

Possible Duplicate:
Nice looking progress bar in java
Working with progressbar

how to change color of jprogressbar in swing using netbeans,by default it taking Orange,i used setbackground but no changes,kindly tell me any easy way.

Community
  • 1
  • 1
user1608338
  • 1
  • 1
  • 1
  • 2
  • hello sir,tell me how to work with UIManager. – user1608338 Aug 24 '12 at 06:58
  • @user1608338: Have a look at my answer and the links to the SO articles that I've posted. Hope that helps :) – Sujay Aug 24 '12 at 07:01
  • aaaach what issue you have got with that, there are three levels(as your questions here), Netbeans GUI Framework, Swing GUI and Nimbus Look and Feel, for better help sooner post an [SSCCE](http://sscce.org/), not your down_voter, but terrible question, sorry :-) – mKorbel Aug 24 '12 at 07:21
  • Well to answer this question, my implicit assumption was based on the progressbar color being `orange` and `NetBeans`. For the remaining part, it was just a guess!! +1 with posting an SSCCE of your problem – Sujay Aug 24 '12 at 07:27

3 Answers3

4

I'm assuming that while you're implementing your code in NetBeans you're using the Nimbus look-and-feel.

It would better serve you to go through these links to understand how you can customize the defaults for this LnF

The following couple of SO articles might also come in handy for you:

Community
  • 1
  • 1
Sujay
  • 6,753
  • 2
  • 30
  • 49
2

Here's a good test to see what JProgressBar colors are:

    JFrame frame = new JFrame("ProgressBar test");
    frame.setSize(300, 300);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JPanel panel = new JPanel();
    frame.add(panel);

    JProgressBar pb = new JProgressBar(50, 100);
    pb.setMinimum(0);
    pb.setMaximum(100);
    pb.setValue(75);
    pb.setForeground(Color.orange);
    pb.setBackground(Color.green);
    panel.add(pb);

    frame.setVisible(true);

You will see from that that setForeground will set the color of the current progress, and setBackground the color of the remaining

Alex Coleman
  • 7,216
  • 1
  • 22
  • 31
1

The method you are looking for is setForeground(Color)

halex
  • 16,253
  • 5
  • 58
  • 67