Java JFileChooser createReportFileChooser(String curDir, File defaultReportFile)

Here you can find the source of createReportFileChooser(String curDir, File defaultReportFile)

Description

create Report File Chooser

License

Open Source License

Declaration

public static JFileChooser createReportFileChooser(String curDir, File defaultReportFile) 

Method Source Code

//package com.java2s;

import java.io.*;

import javax.swing.JFileChooser;

import javax.swing.filechooser.FileFilter;

public class Main {
    public static JFileChooser createReportFileChooser(String curDir, File defaultReportFile) {
        JFileChooser fc = new JFileChooser(curDir);
        fc.setFileFilter(new FileFilter() {
            @Override//from w  w  w . j a  va2s .c  om
            public boolean accept(File f) {
                String filename = f.getName();
                if (filename.endsWith(".html") || filename.endsWith(".htm") || filename.endsWith(".xhtml"))
                    return true;
                return false;
            }

            @Override
            public String getDescription() {
                return "HTML file";
            }
        });
        if (defaultReportFile != null)
            fc.setSelectedFile(defaultReportFile);
        return fc;
    }
}

Related

  1. createFileChooser(String title, File dir, String filter)
  2. createJFileChooser(String name)
  3. createJFileChooserWithExistenceChecking()
  4. createJFileChooserWithOverwritePrompting()
  5. createOpenFileChooser(String title, String dir, Component parent, FileFilter filter)
  6. createUserDefinedProfileFileChooser()
  7. directoryFetch(File starting)
  8. exportFile(JFileChooser fileChooser, String contents)
  9. fileChooser()