Java Utililty Methods JFileChooser Filter

List of utility methods to do JFileChooser Filter

Description

The list of methods to do JFileChooser Filter are organized into topic(s).

Method

javax.swing.filechooser.FileFiltergetBinaryFileFilter()
get Binary File Filter
return getFileFilter("Einfache Speicherabbilddateien (*.bin)", "bin");
FileFiltergetCustomFileFilter(String desc, String[] validExtensions)
get Custom File Filter
final String d = desc;
final String[] ext = validExtensions;
return new FileFilter() {
    @Override
    public boolean accept(File f) {
        if (f.isDirectory())
            return true;
        for (String e : ext) {
...
FileNameExtensionFiltergetFileChooserFilter(java.util.List allowedExtensions)
get File Chooser Filter
String extensionsMsg = "";
int numExtensions = allowedExtensions.size();
String[] allowedFileExtensions = new String[numExtensions];
for (int i = 0; i < numExtensions; i++) {
    if (i > 0)
        extensionsMsg += ", ";
    allowedFileExtensions[i] = allowedExtensions.get(i);
    extensionsMsg += "*." + allowedFileExtensions[i];
...
javax.swing.filechooser.FileFiltergetFileFilter(String text, String... formats)
get File Filter
javax.swing.filechooser.FileFilter rv = null;
if (formats != null) {
    if (formats.length > 0) {
        if (fmt2FileFilter == null) {
            fmt2FileFilter = new Hashtable<String, javax.swing.filechooser.FileFilter>();
        rv = fmt2FileFilter.get(formats[0]);
        if (rv == null) {
...
FileFiltergetFileFilter()
Returns the file filter for this class loader.
return fileFilter;
FileFiltergetFileFilterForExtensions(final String[] exts, final boolean ignoreCase)
get File Filter For Extensions
FileFilter filter = new FileFilter() {
    @Override
    public String getDescription() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < exts.length; i++) {
            if (i != 0) {
                sb.append(", ");
            sb.append("*." + exts[i]);
        return sb.toString();
    @Override
    public boolean accept(File f) {
        if (f == null) {
            return false;
        if (f.isDirectory()) {
            return true;
        } else if (ignoreCase) {
            for (int i = 0; i < exts.length; i++) {
                if (f.getName().toUpperCase().endsWith("." + exts[i].toUpperCase())) {
                    return true;
        } else {
            for (int i = 0; i < exts.length; i++) {
                if (f.getName().endsWith("." + exts[i])) {
                    return true;
        return false;
};
return filter;
String[]getFilterExtensions(FileNameExtensionFilter... filters)
get Filter Extensions
return filters != null ? Arrays.stream(filters).map(filter -> filter.getExtensions())
        .reduce((extensionsA, extensionsB) -> Stream
                .concat(Arrays.stream(extensionsA), Arrays.stream(extensionsB)).toArray(String[]::new))
        .get() : null;
ArrayListgetHostFileFilters()
get Host File Filters
ArrayList<FileNameExtensionFilter> filters = new ArrayList<FileNameExtensionFilter>();
filters.add(new FileNameExtensionFilter("Supported formats (*.bmp, *.png, *.tif, *.tiff)", "bmp", "png",
        "tif", "tiff"));
return filters;
FileFiltergetKCTapFileFilter()
get KC Tap File Filter
return getFileFilter("KC-TAP-Dateien (*.tap)", "tap");
FileFiltergetManikaFileFilter()
get Manika File Filter
return manikaFilter;