public boolean accept(File file) { return file.isDirectory() || file.getName().endsWith(".jar") || file.getName().endsWith(".class"); } public String getDescription() { return "Jar files (*.jar)"; }
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)"; }
    private void browseJarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseJarButtonActionPerformed	JFileChooser chooser = createFileChooser();        FileFilter filter = new FileFilter() {            public boolean accept(File file) { return file.isDirectory() || file.getName().endsWith(".jar")							|| file.getName().endsWith(".class"); }            public String getDescription() { return "Jar files (*.jar)"; }        };        chooser.setFileFilter(filter);        chooser.setMultiSelectionEnabled(true);        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);        	int rc = chooseFile(chooser, "Add Jar file");        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