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)
{ 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)
估计这个bug在后续的jdk中并没有解决,悲剧,我还是查查怎么规避掉这个问题
以前在1.60_10中也遇到过过滤器的异常信息,也是没法子解决
貌似这个文件过滤器底层是相当复杂的
可是我的系统是xp的,jdk是1.6.0_20的也出现了,悲剧