我得到這個運行時錯誤,我想使java文件選擇器看起來像Windows之一。NullPointerException當使用WindowsFileChooserUI
錯誤代碼:
Exception in thread "main" java.lang.NullPointerException
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:306)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:173)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:150)
at Main.getImg(Main.java:49)
at Main.main(Main.java:19)
代碼:
JFileChooser fico = new JFileChooser();
WindowsFileChooserUI wui = new WindowsFileChooserUI(fico);
wui.installUI(fico);
int returnVal = fico.showOpenDialog(null);
我剛剛在你的問題中執行了4行代碼,並沒有例外。你能指定你的問題還是發送更多的代碼? – Juvanis 2012-03-07 03:56:04