📄 jfilefilter.java
字号:
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
public class JFileFilter extends javax.swing.filechooser.FileFilter {
protected String description;
protected ArrayList exts = new ArrayList();
public void addType(String s) {
exts.add(s);
}
/** Return true if the given file is accepted by this filter. */
public boolean accept(File f) {
// Little trick: if you don't do this, only directory names
// ending in one of the extentions appear in the window.
if (f.isDirectory()) {
return true;
} else if (f.isFile()) {
Iterator it = exts.iterator();
while (it.hasNext()) {
if (f.getName().endsWith((String) it.next()))
return true;
}
}
// A file that didn't match, or a weirdo (e.g. UNIX device file?).
return false;
}
/** Set the printable description of this filter. */
public void setDescription(String s) {
description = s;
}
/** Return the printable description of this filter. */
public String getDescription() {
return description;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -