Setting the colors of a JProgressBar text

前端 未结 2 597
南笙
南笙 2020-12-16 21:21

I have these progress bars:

\"Sample

I\'m trying to set the color o

2条回答
  •  感动是毒
    2020-12-16 22:02

    Ah ha - looks like I can modify the UI:

        setUI(new BasicProgressBarUI() {
          protected Color getSelectionBackground() { return Color.black; }
          protected Color getSelectionForeground() { return Color.white; }
        });
    

    This was a bit confusing, since the use of Foreground and Background weren't intuitive. Background is the color of the text when the bar isn't covering it, foreground is the color of the text when it is.

    Here's the end result:

    Colors adjusted

提交回复
热议问题