JFileChooser chooser = new JFileChooser(""); chooser.addChoosableFileFilter(new FileFilter()
{ public boolean accept(File f)
{
if (f.isDirectory()) { return true; }
String fileName = f.getName();
if (fileName.toLowerCase()
.endsWith("rep".toLowerCase())) { return true; }
return false;
} public String getDescription()
{
return "rep " + replayUtil.getString("File")
+ "(*.rep)";
} }); int returnVal = chooser.showOpenDialog(repalyAppStart);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
path = chooser.getSelectedFile().getAbsolutePath();
if (!path.endsWith(".rep"))
{
JOptionPane
.showMessageDialog(
repalyAppStart,
replayUtil
.getString("FileDescriptionError_Message"));
}
else
{
addPathList(path);// 添加到pathList中
// 如果保存路径的面板打开则,设置list
if (null != saveRepPath && saveRepPath.isShowing())
{
saveRepPath.list.setListData(listPath);
}
setReplayAppThread(path);
}
}

Exception in thread "Basic L&F File Loading Thread" java.lang.NullPointerException
at sun.awt.shell.Win32ShellFolder2.pidlsEqual(Win32ShellFolder2.java:498)
at sun.awt.shell.Win32ShellFolder2.equals(Win32ShellFolder2.java:491)
at sun.awt.shell.Win32ShellFolderManager2.isFileSystemRoot(Win32ShellFolderManager2.java:350)
at sun.awt.shell.ShellFolder.isFileSystemRoot(ShellFolder.java:242)
at javax.swing.filechooser.FileSystemView.isFileSystemRoot(FileSystemView.java:323)
at javax.swing.filechooser.WindowsFileSystemView.isTraversable(FileSystemView.java:657)
at javax.swing.JFileChooser.isTraversable(JFileChooser.java:1561)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run0(BasicDirectoryModel.java:232)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:211)

解决方案 »

  1.   

    http://forums.sun.com/thread.jspa?threadID=5434308&start=0&tstart=0据说 1.6.018 没错。可能是 bug。这样的问题如果怀疑跟 JDK 有关系,就直接到 sun 公司网站上搜索,比如 ,这样的 Google 关键字:sun.awt.shell.Win32ShellFolder2.pidlsEqual site:sun.com
      

  2.   

    我刚刚把JDK升级到了1.60_20
    估计这个bug在后续的jdk中并没有解决,悲剧,我还是查查怎么规避掉这个问题
    以前在1.60_10中也遇到过过滤器的异常信息,也是没法子解决
    貌似这个文件过滤器底层是相当复杂的
      

  3.   

    刚刚看了 那个帖子,说的是windows7才会出现这个异常
    可是我的系统是xp的,jdk是1.6.0_20的也出现了,悲剧