我一直在尋找互聯網(當然是經濟實惠的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的價值。什麼是價值?好奇,如果它是空的。 –