FileFilter filter = new FileFilter() { public boolean accept(File file) { if (file.isDirectory()) return true;  String fileName = file.getName(); int dot = fileName.lastIndexOf('.'); if (dot < 0) return false; String extension = fileName.substring(dot); return archiveExtensionSet.contains(extension); } public String getDescription() { return "Java archives (*.jar,*.zip,*.ear,*.war)"; } }; chooser.setFileFilter(filter);
chooser.setFileFilter(archiveAndDirectoryFilter);
    private void browseJarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseJarButtonActionPerformed	JFileChooser chooser = createFileChooser();        FileFilter filter = new FileFilter() {            public boolean accept(File file) {                   if (file.isDirectory())                       return true;                                      String fileName = file.getName();                   int dot = fileName.lastIndexOf('.');                   if (dot < 0)                       return false;                   String extension = fileName.substring(dot);                   return archiveExtensionSet.contains(extension);            }            public String getDescription() { return "Java archives (*.jar,*.zip,*.ear,*.war)"; }        };        chooser.setFileFilter(filter);        chooser.setMultiSelectionEnabled(true);        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);        	int rc = chooseFile(chooser, "Add archive or directory");        if (rc == JFileChooser.APPROVE_OPTION) {            File[] selectedFileList = chooser.getSelectedFiles();            for (int i = 0; i < selectedFileList.length; ++i) {                String entry = selectedFileList[i].getPath();                addJarToProject(entry);            }        }    }//GEN-LAST:event_browseJarButtonActionPerformed