my problem is that i got the progressbar and everything i tried was unsuccessfully. The Color is always that orange and i dont get it away. I rly need help woule be nice if i get a fast answer.



Hello! I suppose you use Nimbus look & feel. And JProgressBar is always orange. But Nimbus is fully customizable, just change the painter.
See it here for details.

Your values to change are:

  • ProgressBar[Disabled+Finished].foregroundPainter
  • ProgressBar[Disabled+Indeterminate].foregroundPainter
  • ProgressBar[Disabled].foregroundPainter
  • ProgressBar[Enabled+Finished].foregroundPainter
  • ProgressBar[Enabled+Indeterminate].foregroundPainter
  • ProgressBar[Enabled].foregroundPainter

The Painter class:

public static class MyPainter implements Painter {

    public void paint(Graphics2D g, Object object, int width, int height) {            
        if (object instanceof javax.swing.JProgressBar){
            Color blueColor = new Color(84, 118, 255);
            Color blueColorWithAlpha = new Color(84, 118, 255, 127);
            GradientPaint GRADIENT_1 = new GradientPaint(0, 0, blueColorWithAlpha, 0, height/2, blueColor);
            g.fillRect(0, 0, width, height/2);
            GradientPaint GRADIENT_2 = new GradientPaint(0, height/2, blueColor, 0, height, blueColorWithAlpha);
            g.fillRect(0, height/2, width, height);


And in your main or init method:

UIManager.put("ProgressBar[Enabled+Finished].foregroundPainter", new MyPainter());
UIManager.put("ProgressBar[Enabled+Indeterminate].foregroundPainter", new MyPainter());
UIManager.put("ProgressBar[Enabled].foregroundPainter", new MyPainter());

The orange is now blue, feel free to change color by your lovely color.

Before: https://1drv.ms/i/s!AunkQ3FeUpyVgbVnKEd9aWarc1q0YA
After: https://1drv.ms/i/s!AunkQ3FeUpyVgbVmSelX08EWT1Qm3Q

commented: Excellent contribution. Thank you +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.