Java JFileChooser createUserDefinedProfileFileChooser()

Here you can find the source of createUserDefinedProfileFileChooser()

Description

Creates a JFileChooser which is appropriate for opening multiple files containing user defined profiles.

License

Open Source License

Return

a JFileChooser

Declaration

public static JFileChooser createUserDefinedProfileFileChooser() 

Method Source Code

//package com.java2s;
/* $Id$/*from   w  w w  . j  a  v  a  2 s . c  om*/
 *****************************************************************************
 * Copyright (c) 2009 Contributors - see below
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    thn
 *****************************************************************************
 *
 * Some portions of this file was previously release using the BSD License:
 */

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;

public class Main {
    /**
     * Creates a JFileChooser which is appropriate for opening multiple files
     * containing user defined profiles.
     * 
     * @return a JFileChooser
     */
    public static JFileChooser createUserDefinedProfileFileChooser() {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser
                .setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        fileChooser.setMultiSelectionEnabled(true);
        fileChooser.setFileFilter(new FileFilter() {

            public boolean accept(File file) {
                String s = file.getName().toLowerCase();
                return file.isDirectory()
                        || (file.isFile() && (s.endsWith(".xmi")
                                || s.endsWith(".xml") || s.endsWith(".uml") // for AndroMDA
                                || s.endsWith(".xmi.zip") || s
                                    .endsWith(".xml.zip")));
            }

            public String getDescription() {
                return "*.xmi *.xml *.xmi.zip *.xml.zip";
            }

        });
        return fileChooser;
    }
}

Related

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