Swing/NimbusLookAndFeel のバックアップ(No.6)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- Swing/NimbusLookAndFeel へ行く。
- 1 (2013-07-24 (水) 21:49:27)
- 2 (2014-12-26 (金) 15:47:12)
- 3 (2016-03-31 (木) 16:25:32)
- 4 (2017-04-04 (火) 14:17:08)
- 5 (2017-04-28 (金) 19:21:31)
- 6 (2018-04-18 (水) 16:21:15)
- 7 (2020-04-09 (木) 14:44:26)
- 8 (2021-10-14 (木) 14:03:04)
- 9 (2025-01-03 (金) 08:57:02)
- 10 (2025-01-03 (金) 09:01:23)
- 11 (2025-01-03 (金) 09:02:38)
- 12 (2025-01-03 (金) 09:03:21)
- 13 (2025-01-03 (金) 09:04:02)
- category: swing
folder: NimbusLookAndFeel
title: NimbusLookAndFeelを使用する
tags: [LookAndFeel, NimbusLookAndFeel, UIManager]
author: aterai
pubdate: 2013-07-22T01:35:03+09:00
description: LookAndFeel一覧からNimbusLookAndFeelを名前で検索取得して使用します。
image:
概要
LookAndFeel
一覧からNimbusLookAndFeel
を名前で検索取得して使用します。Nimbus Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)などのサンプルから引用しています。
Screenshot

Advertisement
サンプルコード
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
// // 以下はJDK 1.7.0 以前を考慮する場合の指定方法
// for (UIManager.LookAndFeelInfo laf: UIManager.getInstalledLookAndFeels()) {
// if ("Nimbus".equals(laf.getName())) {
// UIManager.setLookAndFeel(laf.getClassName());
// }
// }
} catch (ClassNotFoundException | InstantiationException
| IllegalAccessException | UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
}
View in GitHub: Java, Kotlin解説
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