jfc.setFileFilter(new FileFilter() { public boolean accept(File f) { if ((f.getAbsolutePath().toLowerCase().endsWith("." + ext) || f .isDirectory()) && (f.exists() || save)) { return true; } return false; }  public String getDescription() { return desc + " (*." + ext + ")"; } });
jfc.setFileFilter(new SimpleFileFilter(save, ext, desc));
    public static File getFile(final boolean save, final String ext,        final String desc)    {        JFileChooser jfc = new JFileChooser(AbstractRom.getDefaultDir());        jfc.setFileFilter(new FileFilter()        {            public boolean accept(File f)            {                if ((f.getAbsolutePath().toLowerCase().endsWith("." + ext) || f                    .isDirectory())                    && (f.exists() || save))                {                    return true;                }                return false;            }            public String getDescription()            {                return desc + " (*." + ext + ")";            }        });        if ((save ? jfc.showSaveDialog(null) : jfc.showOpenDialog(null)) == JFileChooser.APPROVE_OPTION)        {            File out = jfc.getSelectedFile();            //extension is forced on save.            if (!out.getPath().endsWith("." + ext) && save)                out = new File(out.getPath() + "." + ext);            AbstractRom.setDefaultDir(out.getParent());            return out;        }        else        {            return null;        }    }