• 追加された行はこの色です。
  • 削除された行はこの色です。
---
category: swing
folder: TabAreaBackground
title: JTabbedPaneのタブエリア背景色などをテスト
tags: [JTabbedPane, UIManager, MetalLookAndFeel]
author: aterai
pubdate: 2011-01-03T14:25:13+09:00
description: MetalLookAndFeelのJTabbedPaneで、タブエリアの背景色などを変更するテストをしています。
image: https://lh4.googleusercontent.com/_9Z4BYR88imo/TSFbcaeJLEI/AAAAAAAAAw0/zQFscoerEGk/s800/TabAreaBackground.png
---
* 概要 [#summary]
`MetalLookAndFeel`の`JTabbedPane`で、タブエリアの背景色などを変更するテストをしています。

#download(https://lh4.googleusercontent.com/_9Z4BYR88imo/TSFbcaeJLEI/AAAAAAAAAw0/zQFscoerEGk/s800/TabAreaBackground.png)

* サンプルコード [#sourcecode]
#code(link){{
UIManager.put("TabbedPane.shadow",                Color.GRAY);
UIManager.put("TabbedPane.darkShadow",            Color.GRAY);
UIManager.put("TabbedPane.light",                 Color.GRAY);
UIManager.put("TabbedPane.highlight",             Color.GRAY);
UIManager.put("TabbedPane.tabAreaBackground",     Color.GRAY);
UIManager.put("TabbedPane.unselectedBackground",  Color.GRAY);
UIManager.put("TabbedPane.background",            Color.GRAY);
UIManager.put("TabbedPane.foreground",            Color.WHITE);
UIManager.put("TabbedPane.focus",                 Color.WHITE);
UIManager.put("TabbedPane.contentAreaColor",      Color.WHITE);
UIManager.put("TabbedPane.selected",              Color.WHITE);
UIManager.put("TabbedPane.selectHighlight",       Color.WHITE);
UIManager.put("TabbedPane.borderHightlightColor", Color.WHITE);
}}

* 解説 [#explanation]
上記のサンプルでは、`UIManager.put("TabbedPane.unselectedBackground", Color.GREEN);`などを利用して、`MetalLookAndFeel`でのタブエリアの背景色などを変更することができます。

- `BasicLookAndFeel`、`MetalLookAndFeel`でのみ有効
- `JPanel`タブ内に配置されている`JCheckBox`で、`JTabbedPane`を不透明に設定可能
- `JPanel`タブ内に配置されている`JComboBox`で、`TabbedPane.tabAreaBackground`などのキーを指定し、その色の変更が可能
- タブ文字色は、`JTabbedPane#setForegroundAt(...)`メソッドを使用して切り替え可能

* 参考リンク [#reference]
- [[JTabbedPaneの選択文字色を変更>Swing/ColorTab]]
- [[JTabbedPaneのタブ文字列をハイライト>Swing/TabTitleHighlight]]
- [https://bugs.openjdk.java.net/browse/JDK-8078269 JDK-8078269 JTabbedPane UI Property TabbedPane.tabAreaBackground no longer works - Java Bug System]

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