Swing/ProgressBarSelectionColor のバックアップの現在との差分(No.7)
- category: swing folder: ProgressBarSelectionColor title: JProgressBarの進捗状況と進捗文字列色を変更する tags: [JProgressBar, UIManager, LookAndFeel] author: aterai pubdate: 2014-08-25T00:01:25+09:00 description: JProgressBarの進捗状況の色や、それで塗り潰された場合の進捗文字列色を変更します。 image:
概要
JProgressBar
の進捗状況の色や、それで塗り潰された場合の進捗文字列色を変更します。
Screenshot
Advertisement
サンプルコード
#spandel
//progressBar1
#spanend
#spanadd
// progressBar1: UIManager.put(...)
#spanend
UIManager.put("ProgressBar.foreground", Color.RED);
UIManager.put("ProgressBar.selectionForeground", Color.ORANGE);
UIManager.put("ProgressBar.background", Color.WHITE);
UIManager.put("ProgressBar.selectionBackground", Color.RED);
#spandel
//progressBar2
#spanend
#spanadd
// progressBar2: BasicProgressBarUI
#spanend
progressBar2.setForeground(Color.BLUE);
progressBar2.setBackground(Color.CYAN.brighter());
progressBar2.setUI(new BasicProgressBarUI() {
@Override protected Color getSelectionForeground() {
return Color.PINK;
}
#spanadd
#spanend
@Override protected Color getSelectionBackground() {
return Color.BLUE;
}
});
View in GitHub: Java, Kotlin解説
- 上:
Default
- 中:
UIManager.put(...);
- 中:
UIManager.put(...)
- 文字色:
ProgressBar.foreground
- 背景色:
ProgressBar.background
- 進捗状況で塗り潰された場合の文字色:
ProgressBar.selectionForeground
- 進捗状況の塗り潰し色:
ProgressBar.selectionBackground
-
NimbusLookAndFeel
では、すべて無効 -
WindowsLookAndFeel
では、ProgressBar.background
が無効 -
NimbusLookAndFeel
ではすべて無効 -
WindowsLookAndFeel
ではProgressBar.background
が無効
- 文字色:
- 下:
BasicProgressBarUI
- 文字色:
JProgressBar#setForeground(Color)
で設定 - 背景色:
JProgressBar#setBackground(Color)
で設定 - 進捗状況で塗り潰された場合の文字色:
BasicProgressBarUI#getSelectionForeground()
をオーバーライドして設定 - 進捗状況の塗り潰し色:
BasicProgressBarUI#getSelectionBackground()
をオーバーライドして設定 - 文字色:
JProgressBar#setForeground(Color)
メソッドで設定 - 背景色:
JProgressBar#setBackground(Color)
メソッドで設定 - 進捗状況で塗り潰された場合の文字色:
BasicProgressBarUI#getSelectionForeground()
メソッドをオーバーライドして設定 - 進捗状況の塗り潰し色:
BasicProgressBarUI#getSelectionBackground()
メソッドをオーバーライドして設定
- 文字色: