• 追加された行はこの色です。
  • 削除された行はこの色です。
TITLE:NimbusLookAndFeelのカラーパレット
#navi(../)
RIGHT:Posted by [[aterai]] at 2012-07-30
*NimbusLookAndFeelのカラーパレット [#kf3f6f47]
NimbusLookAndFeelのカラーパレットを変更します。
---
category: swing
folder: NimbusColorPalette
title: NimbusLookAndFeelのカラーパレット
tags: [NimbusLookAndFeel, UIDefaults, JProgressBar]
author: aterai
pubdate: 2012-07-30T13:49:19+09:00
description: NimbusLookAndFeelのカラーパレットを変更します。
image: https://lh4.googleusercontent.com/-ZPZIywXgxwc/UBYR3-EyETI/AAAAAAAABP4/Y2KglYmMKo8/s800/NimbusColorPalette.png
---
* 概要 [#summary]
`NimbusLookAndFeel`のカラーパレットを変更します。

-&jnlp;
-&jar;
-&zip;
#download(https://lh4.googleusercontent.com/-ZPZIywXgxwc/UBYR3-EyETI/AAAAAAAABP4/Y2KglYmMKo8/s800/NimbusColorPalette.png)

//#screenshot
#ref(https://lh4.googleusercontent.com/-ZPZIywXgxwc/UBYR3-EyETI/AAAAAAAABP4/Y2KglYmMKo8/s800/NimbusColorPalette.png)

**サンプルコード [#kb6eef2f]
* サンプルコード [#sourcecode]
#code(link){{
UIDefaults def = UIManager.getLookAndFeelDefaults();
def.put("nimbusOrange", new Color(255,220,35,200));
def.put("nimbusOrange", new Color(255, 220, 35, 200));
}}

**解説 [#j922dab2]
- 上:
-- Nimbus Look&Feel の Primary Colors の一つ(上記のサンプルではnimbusOrange)を変更して全体で色を変更
* 解説 [#explanation]
- 上`JProgressBar`:
-- `NimbusLookAndFeel`の`Primary Colors`の一つ(上記のサンプルでは`nimbusOrange`)を変更して全体で色を変更
-- 以下の一覧表は[https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html Nimbus Defaults (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]からの引用
|240|240|80|c
|Key                       |Value                |Preview          |h
|control                   |#d6d9df (214,217,223)|BGCOLOR(#d6d9df):|
|info                      |#f2f2bd (242,242,189)|BGCOLOR(#f2f2bd):|
|nimbusAlertYellow         |#ffdc23 (255,220,35) |BGCOLOR(#ffdc23):|
|nimbusBase                |#33628c (51,98,140)  |BGCOLOR(#33628c):|
|nimbusDisabledText        |#8e8f91 (142,143,145)|BGCOLOR(#8e8f91):|
|nimbusFocus               |#73a4d1 (115,164,209)|BGCOLOR(#73a4d1):|
|nimbusGreen               |#b0b332 (176,179,50) |BGCOLOR(#b0b332):|
|nimbusInfoBlue            |#2f5cb4 (47,92,180)  |BGCOLOR(#2f5cb4):|
|nimbusLightBackground     |#ffffff (255,255,255)|BGCOLOR(#ffffff):|
|nimbusOrange              |#bf6204 (191,98,4)   |BGCOLOR(#bf6204):|
|nimbusRed                 |#a92e22 (169,46,34)  |BGCOLOR(#a92e22):|
|nimbusSelectedText        |#ffffff (255,255,255)|BGCOLOR(#ffffff):|
|nimbusSelectionBackground |#39698a (57,105,138) |BGCOLOR(#39698a):|
|text                      |#000000 (0,0,0)      |BGCOLOR(#000000):|

以下の一覧は、[http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html Nimbus Defaults (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]より引用
|Key| Value| Preview|h
|control                   | #d6d9df (214,217,223)| COLOR(#d6d9df){■}|
|info                      | #f2f2bd (242,242,189)| COLOR(#f2f2bd){■}|
|nimbusAlertYellow         | #ffdc23 (255,220,35) | COLOR(#ffdc23){■}|
|nimbusBase                | #33628c (51,98,140)  | COLOR(#33628c){■}|
|nimbusDisabledText        | #8e8f91 (142,143,145)| COLOR(#8e8f91){■}|
|nimbusFocus               | #73a4d1 (115,164,209)| COLOR(#73a4d1){■}|
|nimbusGreen               | #b0b332 (176,179,50) | COLOR(#b0b332){■}|
|nimbusInfoBlue            | #2f5cb4 (47,92,180)  | COLOR(#2f5cb4){■}|
|nimbusLightBackground     | #ffffff (255,255,255)| COLOR(#ffffff){■}|
|nimbusOrange              | #bf6204 (191,98,4)   | COLOR(#bf6204){■}|
|nimbusRed                 | #a92e22 (169,46,34)  | COLOR(#a92e22){■}|
|nimbusSelectedText        | #ffffff (255,255,255)| COLOR(#ffffff){■}|
|nimbusSelectionBackground | #39698a (57,105,138) | COLOR(#39698a){■}|
|text                      | #000000 (0,0,0)      | COLOR(#000000){■}|

- 下:
-- 指定した領域を塗りつぶすPainterを作成して、JProgressBar#putClientProperty("Nimbus.Overrides", d); で特定のコンポーネントの色を設定

- 下`JProgressBar`:
-- 指定した領域を塗りつぶす`Painter`を作成して`JProgressBar#putClientProperty("Nimbus.Overrides", d)`で特定のコンポーネントの色を設定
#code{{
UIDefaults d = new UIDefaults();
d.put("ProgressBar[Enabled].foregroundPainter", new Painter() {
  @Override public void paint(Graphics2D g, Object o, int w, int h) {
    g.setColor(new Color(100,250,120,50));
    g.fillRect(0,0,w-1,h-1);
    g.setColor(new Color(100,250,120,150));
    g.fillRect(3,h/2,w-5,h/2-2);
d.put("ProgressBar[Enabled].foregroundPainter", new Painter<JProgressBar>() {
  @Override public void paint(Graphics2D g, JProgressBar c, int w, int h) {
    g.setColor(new Color(100, 250, 120, 50));
    g.fillRect(0, 0, w - 1, h - 1);
    g.setColor(new Color(100, 250, 120, 150));
    g.fillRect(3, h / 2, w - 5, h / 2 - 2);
  }
});
progressbar.putClientProperty("Nimbus.Overrides", d);
}}

**参考リンク [#je95a8c5]
- [http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html Nimbus Defaults (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]
- [http://stackoverflow.com/questions/10847308/how-to-change-the-color-of-a-single-jprogressbar-in-nimbus java - How to change the color of a single JProgressBar in Nimbus? - Stack Overflow]
* 参考リンク [#reference]
- [https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html Nimbus Defaults (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]
- [https://stackoverflow.com/questions/10847308/how-to-change-the-color-of-a-single-jprogressbar-in-nimbus java - How to change the color of a single JProgressBar in Nimbus? - Stack Overflow]
- [[JLayerを使ってJProgressBarの色相を変更する>Swing/ColorChannelSwapFilter]]
-- こちらは`JLayer`+`RGBImageFilter`で`JProgressBar`全体の色を変更するサンプル

**コメント [#x2d9373f]
* コメント [#comment]
#comment
#comment