2012-05-27 110 views

回答

22

我認爲這些值是適合你

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

看起來不錯。要麼完全改變L&F。對於'UIManager',1 + –

+0

+1;另請參閱此[備選](http://stackoverflow.com/a/8886795/230513)。 – trashgod

+0

+1這個答案,但我不知道怎麼知道Key'的'價值,我怎麼會知道'UIManager.put(ProgressBar.whatElseCanIWriteHere,myvalue的)',沒有任何文件,其中討論了這一部分,如果有是其中之一,請點我吧,我是非常感激:-) –

14

您應該將setStringPainted屬性設置爲true:

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

謝謝,這是設置一個單獨的顏色的最佳途徑。 – Stefan

+2

但是,這將改變文本顏色,而不是進度顏色。 – Matthieu

+1

試試吧,它改變了進度條的前景 – Alex