JFileChooser fd = new JFileChooser();
//用内部匿名类自定义过滤器,只看见txt文件
fd.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
return f.getName().endsWith(".txt");
}
@Override
public String getDescription() {
return ".txt";
}
});
JFileChooser过滤器,布布扣,bubuko.com
原文:http://www.cnblogs.com/lxm123/p/3675443.html