Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change JProgressBar color?

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

like image 912
Ali Bassam Avatar asked May 27 '12 12:05

Ali Bassam


2 Answers

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);
like image 110
mKorbel Avatar answered Nov 11 '22 12:11

mKorbel


You should set the setStringPainted property to true:

progressBar.setStringPainted(true);
progressBar.setForeground(Color.blue);
progressBar.setString("10%");
like image 27
Alexey Avatar answered Nov 11 '22 11:11

Alexey