FileDocCategorySizeDatePackage
JFileFilter.javaAPI DocExample1178Wed Jan 26 22:39:56 GMT 2000None

JFileFilter

public class JFileFilter extends FileFilter
A simple FileFilter class that works by filename extension, like the one in the JDK demo called ExtentionFilter, which has been announced to be supported in a future Swing release.

Fields Summary
protected String
description
protected ArrayList
exts
Constructors Summary
Methods Summary
public booleanaccept(java.io.File f)
Return true if the given file is accepted by this filter.

		// 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;
	
public voidaddType(java.lang.String s)


	    
		exts.add(s);
	
public java.lang.StringgetDescription()
Return the printable description of this filter.

		return description;
	
public voidsetDescription(java.lang.String s)
Set the printable description of this filter.

		description = s;