我一直在寻找互联网(当然是经济实惠的StackOverflow :))以下问题。 Netbeans提供了一个'很棒'的默认外观和感觉,所以我想将其改为原生外观。我的意思是,正在运行的程序看起来不像设计的GUI。因此,当您选择设计在Windows PC上,程序看起来像Windows,因此适用于Mac等本机操作系统的外观和感觉Netbeans不适用于UIManager.setLookAndFeel(nativeLF);
所以,我搜索这个网站上,发现了很多的时间的示例代码:
private void setLookAndFeel() {
// Get the native look and feel class name
String nativeLF = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(nativeLF);
} catch (ClassNotFoundException | InstantiationException |
IllegalAccessException | UnsupportedLookAndFeelException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
source: http://www.exampledepot.com/egs/javax.swing/LookFeelNative.html
但是...它不会为我工作。
我会得到一个nullpointerexception,这是很长的(584行)。
我希望有人能帮助我。
在此先感谢!
戴夫
Backgroundinformation: - Netbeans的7.1.2 - Windows 7的 - 不会以这种方式工作:http://www.exampledepot.com/egs/javax.swing/LookFeelNative.html
请修改您的代码示例调用getSystemLookAndFeelClassName和try块之前后打印出来nativeLF的价值。什么是价值?好奇,如果它是空的。 –