Here you can find the source of getFiles(String title, String initialRoot, String initialFile)
public static String[][] getFiles(String title, String initialRoot, String initialFile)
//package com.java2s; /*----------------------------------------------------------------------------- * vlsSMLM Software/*w ww .j a va 2 s . co m*/ * * Copyright (C) 2014 Matthieu Palayret * Department of Chemistry * University of Cambridge, UK * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. *---------------------------------------------------------------------------*/ import java.io.File; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class Main { public static String[][] getFiles(String title, String initialRoot, String initialFile) { if (title == null || title == "") title = "Choose files"; if (initialRoot == null || initialRoot == "") initialRoot = "E:\\Data"; JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); FileNameExtensionFilter filter = new FileNameExtensionFilter( "Tiff files", "tif", "tiff"); chooser.setFileFilter(filter); chooser.setDialogTitle(title); chooser.setCurrentDirectory(new File(initialRoot)); chooser.setMultiSelectionEnabled(true); int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { String[][] files = new String[chooser.getSelectedFiles().length][2]; for (int i = 0; i < files.length; i++) { files[i][0] = chooser.getSelectedFiles()[i].getParent(); files[i][1] = chooser.getSelectedFiles()[i].getName(); } return files; } else return null; } }