• 追加された行はこの色です。
  • 削除された行はこの色です。
TITLE:NimbusLookAndFeelを使用する
#navi(../)
#tags(LookAndFeel, NimbusLookAndFeel, UIManager)
RIGHT:Posted by &author(aterai); at 2013-07-22
*NimbusLookAndFeelを使用する [#dc5c278f]
``LookAndFeel``一覧から``NimbusLookAndFeel``を名前で検索取得して使用します。[http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html Nimbus Look and Feel (The Java? Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]などのサンプルから引用しています。
---
title: NimbusLookAndFeelを使用する
tags: [LookAndFeel, NimbusLookAndFeel, UIManager]
author: aterai
pubdate: 2013-07-22T01:35:03+09:00
description: LookAndFeel一覧からNimbusLookAndFeelを名前で検索取得して使用します。
---
* 概要 [#dc5c278f]
`LookAndFeel`一覧から`NimbusLookAndFeel`を名前で検索取得して使用します。[http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html Nimbus Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]などのサンプルから引用しています。

-&jnlp;
-&jar;
-&zip;
#download(https://lh5.googleusercontent.com/-40dXjNq1HbU/UewL67WFpWI/AAAAAAAABwg/zOHVr2U7KiM/s800/NimbusLookAndFeel.png)

//#screenshot
#ref(https://lh5.googleusercontent.com/-40dXjNq1HbU/UewL67WFpWI/AAAAAAAABwg/zOHVr2U7KiM/s800/NimbusLookAndFeel.png)

**サンプルコード [#ub4d63c2]
* サンプルコード [#ub4d63c2]
#code(link){{
try{
  for(UIManager.LookAndFeelInfo laf: UIManager.getInstalledLookAndFeels()) {
    if("Nimbus".equals(laf.getName())) {
      UIManager.setLookAndFeel(laf.getClassName());
    }
  }
}catch(Exception e) {
  //e.printStackTrace();
}
}}

**解説 [#zb2d6bfe]
``JDK 1.7.0``で``NimbusLookAndFeel``のパッケージが移動されて完全クラス名が変更されたので、``NimbusLookAndFeel``のインスタンスを生成して設定するのではなく、一旦``UIManager.getInstalledLookAndFeels()``で全``LookAndFeelInfo``を取得し、名前が``Nimbus``となっている``LookAndFeel``を検索してからその完全クラス名を取得しています。
* 解説 [#zb2d6bfe]
`JDK 1.7.0`で`NimbusLookAndFeel`のパッケージが移動されて完全クラス名が変更されたので、`NimbusLookAndFeel`のインスタンスを生成して設定するのではなく、一旦`UIManager.getInstalledLookAndFeels()`で全`LookAndFeelInfo`を取得し、名前が`Nimbus`となっている`LookAndFeel`を検索してからその完全クラス名を取得しています。

- ``JDK 1.6.0_10``: ``com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel``
- ``JDK 1.7.0``: ``javax.swing.plaf.nimbus.NimbusLookAndFeel``
- `JDK 1.6.0_10`: `com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel`
- `JDK 1.7.0`: `javax.swing.plaf.nimbus.NimbusLookAndFeel`

**参考リンク [#b9019d38]
- [http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html Nimbus Look and Feel (The Java? Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]
* 参考リンク [#b9019d38]
- [http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html Nimbus Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)]

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