Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public class Main {
    /**
     * 
     * Example usage:
     * <pre>
     * SwingUtil.createFileFilter("JEQL script (*.jql)", "jql")
     * </pre>
     * @param description
     * @param extension
     * @return the file filter
     */
    public static FileFilter createFileFilter(final String description, String extension) {
        final String dotExt = extension.startsWith(".") ? extension : "." + extension;
        FileFilter ff = new FileFilter() {
            public String getDescription() {
                return description;
            }

            public boolean accept(File f) {
                return f.isDirectory() || f.toString().toLowerCase().endsWith(dotExt);
            }
        };
        return ff;
    }
}