我在 netbeans 7.2 中用 java 创建了一个 gui 应用程序。我在那里创建了一个 JFrame
。它在自动生成的代码中被设置为灵光外观。但我的框架看起来不像灵气。
所以我调试了代码,发现 nimbus 在 getInstalledLookAndFeels()
返回的数组中不可用。
那么我应该怎么做才能安装 nimbus 外观? JDK 1.6 用于编译代码。
最佳答案
确保您的 java 版本高于: JDK 6 更新 10。
See here :
Nimbus is a polished cross-platform look and feel introduced in the Java SE 6 Update 10 (6u10) release.
您可以在这里下载最新的 Java (7u9) 和 Netbeans (7.2.1) 版本(捆绑):
在那之后你就可以开始了,不要忘记在 Event Disptach Thread
中设置 L&F:
//Create UI and set L&F on EDT
SwingUtilities.invokeLater(new Runnable( ) {
public void run( ) {
//set L&F
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
e.printStackTrace();
}
//create UI and components here
}
});
关于java - 灵气外观不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13177534/