List of usage examples for javax.swing JFileChooser getSelectedFiles
public File[] getSelectedFiles()
From source file:smlm.util.SRutil.java
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);/* ww w . java 2 s . c om*/ 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; }
From source file:uk.ac.liverpool.narrative.SolutionGraphics.java
@Override public void run() { // set up action cost filter if (actionCostsFilePath != null && (new File(actionCostsFilePath)).exists()) { CharacterActionSolutionFilter tc = new CharacterActionSolutionFilter(); if (actionCostsFilePath != null && (new File(actionCostsFilePath)).exists()) { tc.setActionCosts(BranchingStoryGenerator.readCosts(actionCostsFilePath, BranchingStoryGenerator.actionCostType)); }/*from w w w . ja v a 2s .co m*/ if (characterCostsFilePath != null && (new File(characterCostsFilePath)).exists()) { tc.setCharacterCosts(BranchingStoryGenerator.readCosts(characterCostsFilePath, BranchingStoryGenerator.characterCostType)); } if (authorDirection != null && (new File(authorDirection)).exists()) { tc.setAuthorDirection( BranchingStoryGenerator.readCosts(authorDirection, BranchingStoryGenerator.authorCostType) .get(BranchingStoryGenerator.authorCostType)); } sg.filters.add(tc); tc.setThreshold(threshold); } if (character != null) { charFilter = new CharacterFilter(character); } if (fc) { JFileChooser fc = new JFileChooser(BranchingStoryGenerator.DestinationFolder); fc.setAccessory(new SolutionPreview(fc)); FileNameExtensionFilter filter = new FileNameExtensionFilter("Solution files", "sol"); fc.setFileFilter(filter); fc.setMultiSelectionEnabled(true); fc.showOpenDialog(vvv); File[] files = fc.getSelectedFiles(); for (File f : files) { try { sg.readSolutionFile(f); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else { for (File f : BranchingStoryGenerator.DestinationFolder.listFiles()) { if (!f.isFile() || !f.getName().endsWith(".sol")) { continue; } try { sg.readSolutionFile(f); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } System.out.println("done"); }
From source file:umich.ms.batmass.filesupport.core.actions.importing.ImportFileByCategory.java
/** * //from w w w . j a v a2 s.com * @param fcBuilder * @return */ protected File[] showMultiOpenDialog(FileChooserBuilder fcBuilder) { JFileChooser chooser = fcBuilder.createFileChooser(); BMFileView bmFileView = new BMFileView(getFileCategory()); chooser.setFileView(bmFileView); chooser.setMultiSelectionEnabled(true); int result = chooser.showOpenDialog(findDialogParent()); if (JFileChooser.APPROVE_OPTION == result) { File[] files = chooser.getSelectedFiles(); return files == null ? new File[0] : files; } else { return null; } }
From source file:view.CertificateManagementDialog.java
private void btnAddCertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddCertActionPerformed JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.showOpenDialog(null);// w w w .j a v a 2s.c o m File[] files = chooser.getSelectedFiles(); final ArrayList<Certificate> toAddList = new ArrayList<>(); for (File file : files) { try { CertificateFactory fact = CertificateFactory.getInstance("X.509"); FileInputStream is = new FileInputStream(file); Certificate cert = fact.generateCertificate(is); toAddList.add(cert); } catch (Exception ex) { } } if (!toAddList.isEmpty()) { String password = getUserInputPassword(); if (password == null) { return; } addCertsToKeystore(toAddList, password); refresh(keystore); } }
From source file:wqm.util.ProcessDataGUI.java
public static void main(String[] args) throws IOException, ParseException { JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Select data file."); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(true);//from w w w . j av a 2 s .c o m int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File[] files = fc.getSelectedFiles(); fc.setDialogTitle("Select output location."); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false); returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File outputDirectory = fc.getSelectedFile(); for (File inputFile : files) { ProcessData .main(new String[] { inputFile.getAbsolutePath(), outputDirectory.getAbsolutePath() }); } } } }
From source file:xtrememp.PlaylistManager.java
public void addFilesDialog(boolean playFirst) { JFileChooser fileChooser = new JFileChooser(Settings.getLastDir()); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.addChoosableFileFilter(audioFileFilter); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setMultiSelectionEnabled(true); if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File[] selectedFiles = fileChooser.getSelectedFiles(); Settings.setLastDir(selectedFiles[0].getParent()); addFiles(Arrays.asList(selectedFiles), playFirst); }/*w w w .ja v a 2 s. c o m*/ }