2012-05-27 57 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