Swing 设置JProgressBar文本的颜色
我有这些进度条:Swing 设置JProgressBar文本的颜色,swing,jprogressbar,Swing,Jprogressbar,我有这些进度条: 我试图设置进度条文本的颜色,而不改变背景颜色或进度条本身的颜色。据我所知,set前台()同时设置文本和条颜色?有没有办法做到一个不做另一个?啊哈-看起来我可以修改UI: setUI(new BasicProgressBarUI() { protected Color getSelectionBackground() { return Color.black; } protected Color getSelectionForeground()
我试图设置进度条文本的颜色,而不改变背景颜色或进度条本身的颜色。据我所知,set前台()同时设置文本和条颜色?有没有办法做到一个不做另一个?啊哈-看起来我可以修改UI:
setUI(new BasicProgressBarUI() {
protected Color getSelectionBackground() { return Color.black; }
protected Color getSelectionForeground() { return Color.white; }
});
这有点混乱,因为前景和背景的使用并不直观。背景是条未覆盖时文本的颜色,前景是条未覆盖时文本的颜色
以下是最终结果:
通过带有默认值的消息
ProgressBar.background is the background color
ProgressBar.foreground is the cell color
ProgressBar.selectionBackground is the text color outside cells
ProgressBar.selectionForeground is the text colot INSIDE cells
UIManager.put("ProgressBar.selectionForeground", Color.black);
UIManager.put("ProgressBar.selectionBackground", Color.black);