How to change JProgressBar color?

I Used .setBackground and .setForeground and they didn't work, the color is like Orange, can't change it.


Solution 1:

I think that these values are right for you

UIManager.put("ProgressBar.background", Color.ORANGE);
UIManager.put("ProgressBar.foreground", Color.BLUE);
UIManager.put("ProgressBar.selectionBackground", Color.RED);
UIManager.put("ProgressBar.selectionForeground", Color.GREEN);

Solution 2:

You should set the setStringPainted property to true:

progressBar.setStringPainted(true);
progressBar.setForeground(Color.blue);
progressBar.setString("10%");