これらの進行状況バーがあります:
背景色や進行状況バー自体の色を変更せずに、進行状況バーの TEXT の色を設定しようとしています。私が知る限り、setForeground() はテキストとバーの色の両方を設定しますか? 一方を他方なしで行う方法はありますか?
これらの進行状況バーがあります:
背景色や進行状況バー自体の色を変更せずに、進行状況バーの TEXT の色を設定しようとしています。私が知る限り、setForeground() はテキストとバーの色の両方を設定しますか? 一方を他方なしで行う方法はありますか?
ああ、UI を変更できるようです。
setUI(new BasicProgressBarUI() {
protected Color getSelectionBackground() { return Color.black; }
protected Color getSelectionForeground() { return Color.white; }
});
Foreground と Background の使用は直感的ではなかったため、これは少し混乱しました。背景は、バーがテキストを覆っていないときのテキストの色であり、前景は、バーが覆っているときのテキストの色です。
最終結果は次のとおりです。
UIDefaultsのメッセージで、
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);