• 追加された行はこの色です。
  • 削除された行はこの色です。
---
category: swing
folder: SystemColor
title: SystemColorの使用
tags: [SystemColor]
author: aterai
pubdate: 2003-10-20
description: Swingコンポーネントの色をSystemColorクラスから取得します。
image: https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTUESCOFBI/AAAAAAAAAlc/eXW_0wilSew/s800/SystemColor.png
---
* 概要 [#summary]
`Swing`コンポーネントの色を`SystemColor`クラスから取得します。

#download(https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTUESCOFBI/AAAAAAAAAlc/eXW_0wilSew/s800/SystemColor.png)

* サンプルコード [#sourcecode]
#code(link){{
Color color = SystemColor.textHighlightText;
Box box = Box.createVerticalBox();
box.add(makeSystemColorPanel(SystemColor.desktop, "desktop"));
box.add(makeSystemColorPanel(SystemColor.activeCaption, "activeCaption"));
box.add(makeSystemColorPanel(SystemColor.inactiveCaption, "inactiveCaption"));
box.add(makeSystemColorPanel(SystemColor.activeCaptionText, "activeCaptionText"));
box.add(makeSystemColorPanel(SystemColor.inactiveCaptionText, "inactiveCaptionText"));
box.add(makeSystemColorPanel(SystemColor.activeCaptionBorder, "activeCaptionBorder"));
box.add(makeSystemColorPanel(SystemColor.inactiveCaptionBorder, "inactiveCaptionBorder"));
box.add(makeSystemColorPanel(SystemColor.window, "window"));
box.add(makeSystemColorPanel(SystemColor.windowText, "windowText"));
box.add(makeSystemColorPanel(SystemColor.menu, "menu"));
box.add(makeSystemColorPanel(SystemColor.menuText, "menuText"));
box.add(makeSystemColorPanel(SystemColor.text, "text"));
box.add(makeSystemColorPanel(SystemColor.textHighlight, "textHighlight"));
box.add(makeSystemColorPanel(SystemColor.textText, "textText"));
box.add(makeSystemColorPanel(SystemColor.textHighlightText, "textHighlightText"));
box.add(makeSystemColorPanel(SystemColor.control, "control"));
box.add(makeSystemColorPanel(SystemColor.controlLtHighlight, "controlLtHighlight"));
box.add(makeSystemColorPanel(SystemColor.controlHighlight, "controlHighlight"));
box.add(makeSystemColorPanel(SystemColor.controlShadow, "controlShadow"));
box.add(makeSystemColorPanel(SystemColor.controlDkShadow, "controlDkShadow"));
box.add(makeSystemColorPanel(SystemColor.controlText, "controlText"));
box.add(makeSystemColorPanel(SystemColor.control, "control"));
box.add(makeSystemColorPanel(SystemColor.scrollbar, "scrollbar"));
box.add(makeSystemColorPanel(SystemColor.info, "info"));
box.add(makeSystemColorPanel(SystemColor.infoText, "infoText"));
}}

* 解説 [#explanation]
各プラットフォームのデスクトップデザインに対応したシステムカラーは、`SystemColor`クラスの`static`フィールドにまとめて定義されています。例えば、`Windows`プラットフォームでデスクトップのカスタマイズでテーマなどを変更すると、この`SystemColor`も動的にその変更に追従します。
各プラットフォームのデスクトップデザインに対応したシステムカラーは、`SystemColor`クラスの`static`フィールドにまとめて定義されています。例えば`Windows`プラットフォームでデスクトップのカスタマイズでテーマなどを変更すると、この`SystemColor`も動的にその変更に追従します。

- メモ
-- `LookAndFeel`を変更しても`SystemColor`は変化しない
-- `GTKLookAndFeel`がシステムデフォルトになる環境では`SystemColor`を取得することが出来ない
- `LookAndFeel`を変更しても`SystemColor`は変化しない
- `GTKLookAndFeel`がシステムデフォルトになる環境では`SystemColor`を取得不可

* 参考リンク [#reference]
- [http://www.asahi-net.or.jp/~dp8t-asm/java/tips/SystemColor.html システムカラー]
- [https://docs.oracle.com/javase/jp/8/docs/api/java/awt/SystemColor.html SystemColor (Java Platform SE 8)]
- [https://docs.oracle.com/javase/jp/8/docs/api/java/awt/Color.html#getColor-java.lang.String- Color#getColor(...) (Java Platform SE 8)]
// - [http://www.asahi-net.or.jp/~dp8t-asm/java/tips/SystemColor.html システムカラー]

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