Java FileFilter
- by Mr CooL
public class DocFilter extends FileFilter {
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String extension = Utils.getExtension(f);
if (extension != null) {
if (extension.equals(Utils.doc) ||
extension.equals(Utils.docx) )
{
return true;
} else {
return false;
}
}
return false;
}
//The description of this filter
public String getDescription() { return "Just Document Files"; }
}
Netbeans compiler warned with the error, "No interface expected here" for above code
Anyone has idea what was the problem?? I tried changing the 'extends' to 'implements', however, it didn't seem to work that way.
and when I changed to implements, the following code cannot work,
chooser.addChoosableFileFilter(new DocFilter());
and with this error,
"method addChoosableFileFilter in class javax.swing.JFileChooser cannot be applied to given types required: javax.swing.filechooser.FileFilter"
Can anyone help on this? Thanks..