Java JFileChooser openDataFileChooser(Component com)

Here you can find the source of openDataFileChooser(Component com)

Description

File chooser to read data files.

License

Open Source License

Parameter

Parameter Description
com parent frame.

Declaration

public static JFileChooser openDataFileChooser(Component com) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;

import javax.swing.*;
import javax.swing.filechooser.*;

public class Main {
    /**/*from  w ww  .j av  a 2  s  .com*/
     * File chooser to read data files.
     * 
     * @param com
     *            parent frame.
     * @return
     */
    public static JFileChooser openDataFileChooser(Component com) {

        JFileChooser fileChooser = new JFileChooser();
        fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
        // fileChooser.setCurrentDirectory(new
        // File(System.getProperty("user.home")));
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        fileChooser.addChoosableFileFilter(
                new FileNameExtensionFilter("All *.jser,*.jxml,*.jpbu,*.jdat,*.root,*.aida,*.xml", "jser", "jxml",
                        "jpbu", "jdat", "root", "aida", "xml"));
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("HFile (*.jser)", "jser"));
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("HFileXML (*.jxml)", "jxml"));
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("PFile (*.jpbu)", "jpbu"));
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("HBook (*.jdat)", "jdat"));
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("ROOT (*.root)", "root"));
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("AIDA (*.aida *.xml)", "aida", "xml"));
        fileChooser.setAcceptAllFileFilterUsed(true);
        return fileChooser;

    }
}

Related

  1. isDriveTraversable(File drive)
  2. loadFile()
  3. loadFile(Component parent, String title)
  4. loadFileAs(Class clazz, String json)
  5. makeFileChooser()
  6. openFile()
  7. openFile(String fileExtension)
  8. promptFile(File file, FileFilter filter, String title)
  9. promptForFilename(String title)