import javax.swing.filechooser.FileFilter; import java.io.File; public class fileTypeImage extends FileFilter //Filter file extensions for a fileChooser { private final String[] strAcceptedExt = {"gif", "jpg", "jpeg"}; //List of accepted extensions private final String strDes = "gif (*.gif) || jpg (*.jpg)"; public boolean accept (File f) { if (f.isDirectory()) { return true; } String strExt = pmValidData.getFileExt(f.getName()); //Loops through all of the acceptable extensions and tests if the supplied extension matches for (int i = 0; i < strAcceptedExt.length; i++) { if (strExt.equalsIgnoreCase(strAcceptedExt[i])) { return true; } } return false; } public String getDescription () { return strDes; } }