Here you can find the source of getFilesToOpen(File startDirectory, Component parent, String... filters)
public static File[] getFilesToOpen(File startDirectory, Component parent, String... filters)
//package com.java2s; //License from project: Open Source License import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.Component; import java.io.File; public class Main { public static File[] getFilesToOpen(File startDirectory, Component parent, String... filters) { JFileChooser chooser = new JFileChooser(startDirectory); FileNameExtensionFilter filter = new FileNameExtensionFilter("Soubory " + toString(filters), filters); chooser.setFileFilter(filter);//from w w w. j av a 2s.c o m chooser.setMultiSelectionEnabled(true); int returnValue = chooser.showOpenDialog(parent); if (returnValue == JFileChooser.APPROVE_OPTION) { return chooser.getSelectedFiles(); } return new File[0]; } private static String toString(String[] filters) { StringBuilder sb = new StringBuilder(); sb.append(filters[0]); for (int i = 1; i < filters.length; i++) { sb.append(", ").append(filters[1]); } return sb.toString(); } }