List of usage examples for javax.swing JFileChooser getSelectedFiles
public File[] getSelectedFiles()
From source file:os.Controller.java
public void browse() { FileNameExtensionFilter filter = new FileNameExtensionFilter("PDF Files", "pdf", "PDF"); JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileFilter(filter);/*from ww w .jav a 2 s. c om*/ fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.setMultiSelectionEnabled(true); fileChooser.showOpenDialog(null); File[] files = fileChooser.getSelectedFiles(); try { // if (checkSelection(files) == true) { // singleThread(files); multiThread(files); } catch (Exception ex) { Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex); } selectedTxt.append("You've selected " + files.length + " PDF file(s).\n"); // } else { // JOptionPane.showMessageDialog(fileChooser, "Please select PDF file(s) only"); // } }
From source file:phex.gui.common.FileDialogHandler.java
private static File[] openDefaultMultiChooser(Component parent, JFileChooser chooser) { chooser.setMultiSelectionEnabled(true); int returnVal = chooser.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { return chooser.getSelectedFiles(); }/* w w w. j a v a2 s . c o m*/ return null; }
From source file:plugin.notes.gui.NotesView.java
/** * {@literal handle File->Open.} Will open any .gmn files, and import them into your * notes structure/*from w w w .ja va2 s.co m*/ */ public void handleOpen() { // TODO fix String sFile = SettingsHandler.getGMGenOption(OPTION_NAME_LASTFILE, System.getProperty("user.dir")); File defaultFile = new File(sFile); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(defaultFile); chooser.addChoosableFileFilter(getFileType()); chooser.setFileFilter(getFileType()); chooser.setMultiSelectionEnabled(true); Component component = GMGenSystem.inst; Cursor originalCursor = component.getCursor(); component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); int option = chooser.showOpenDialog(GMGenSystem.inst); if (option == JFileChooser.APPROVE_OPTION) { for (File noteFile : chooser.getSelectedFiles()) { SettingsHandler.setGMGenOption(OPTION_NAME_LASTFILE, noteFile.toString()); if (noteFile.toString().endsWith(EXTENSION)) { openGMN(noteFile); } } } GMGenSystem.inst.setCursor(originalCursor); refreshTree(); }
From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java
public static void addFileMenu(final JFrame frame, JMenuBar menuBar) { // Create a menu JMenu menu = new JMenu("File"); menuBar.add(menu);/*from w ww. j a v a 2 s . com*/ // Create a file open iten JMenuItem openFileItem = new JMenuItem("Open files..."); openFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setApproveButtonText("Convert to MITAB25"); // Enable multiple selections chooser.setMultiSelectionEnabled(true); // Show the dialog; wait until dialog is closed chooser.showOpenDialog(frame); // Retrieve the selected files. This method returns empty // if multiple-selection mode is not enabled. File[] files = chooser.getSelectedFiles(); if (files != null && files.length > 0) { FilesProcessor processor = new FilesProcessor(); processor.process(frame, files, expansionStrategy, postProcessorStrategy, aggregateSelectedFiles); } } }); menu.add(openFileItem); // Create an exit final JMenuItem mergeItem = new JCheckBoxMenuItem("Aggregate all selected files", aggregateSelectedFiles); mergeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // If selected, all files dropped or selected at once are aggregated into a single MITAB file aggregateSelectedFiles = mergeItem.isSelected(); log.debug("Aggregate is " + aggregateSelectedFiles); } }); menu.add(mergeItem); // Create an exit JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); menu.add(exitItem); }
From source file:rmeteorj.GUI.GUI.java
/** * Open file for detection or analysis//w ww . j av a 2 s . c o m */ public static void openFile() { JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Open file"); fc.setMultiSelectionEnabled(true); int response = fc.showOpenDialog(MainWindow.getInstance()); if (response == JFileChooser.APPROVE_OPTION) { String[] options = ArrayUtils.addAll(ModuleManager.getManager().getEnabledDetectModulesNames(), ModuleManager.getManager().getEnabledAnalyzeModulesNames()); if (options.length == 0) { JOptionPane.showMessageDialog(MainWindow.getInstance(), "Enable detect or analyze module first."); return; } options[options.length] = "Cancel"; String moduleName = (String) JOptionPane.showInputDialog(MainWindow.getInstance(), "Send opened files to: ", "Open file", JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (!moduleName.equals("Cancel")) { ModuleManager.getManager().openFilesAnalyzeOrDetect(fc.getSelectedFiles(), moduleName); } } }
From source file:ropes.MainWindow.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed //TODO display loader animation while liberys are loading DefaultTreeModel model = (DefaultTreeModel) jTree_fileList.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); final JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.setMultiSelectionEnabled(true);//from w w w.j a v a 2s .c om int returnVal = fc.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File[] files = fc.getSelectedFiles(); for (File file : files) { if (file.isFile()) { addFileToList(file); } else if (file.isDirectory()) { //adds the parent to tree root.add(new DefaultMutableTreeNode(file)); //adds all the subfolders and files to the parent addFileRecursive(file.toString()); } } } }
From source file:se.trixon.mapollage.ui.config.ModuleSourcePanel.java
@Override public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) { JFileChooser fileChooser = fileChooserPanel.getFileChooser(); if (fileChooserPanel == sourceChooserPanel) { if (fileChooser.isMultiSelectionEnabled()) { String paths = StringUtils.join(fileChooser.getSelectedFiles(), File.pathSeparator); fileChooserPanel.setPath(paths); }/*from w w w . j av a2 s . c o m*/ saveSourcePath(); } }
From source file:se.trixon.toolbox.checksum.ChecksumTopComponent.java
@Override public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) { JFileChooser fileChooser = fileChooserPanel.getFileChooser(); if (fileChooserPanel == sourceChooserPanel) { logPanel.clear();/* ww w. j a v a 2s .com*/ if (fileChooser.isMultiSelectionEnabled()) { String paths = StringUtils.join(fileChooser.getSelectedFiles(), SystemUtils.PATH_SEPARATOR); fileChooserPanel.setPath(paths); } } }
From source file:se.trixon.toolbox.dbtext.DbTextTopComponent.java
@Override public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) { JFileChooser fileChooser = fileChooserPanel.getFileChooser(); if (fileChooserPanel == sourceChooserPanel) { if (fileChooser.isMultiSelectionEnabled()) { String paths = StringUtils.join(fileChooser.getSelectedFiles(), SystemUtils.PATH_SEPARATOR); fileChooserPanel.setPath(paths); }/*www . j a v a 2s . c o m*/ } }
From source file:se.trixon.toolbox.photokml.config.ModuleSourcePanel.java
@Override public void onFileChooserOk(FileChooserPanel fileChooserPanel, File file) { JFileChooser fileChooser = fileChooserPanel.getFileChooser(); if (fileChooserPanel == sourceChooserPanel) { if (fileChooser.isMultiSelectionEnabled()) { String paths = StringUtils.join(fileChooser.getSelectedFiles(), SystemUtils.PATH_SEPARATOR); fileChooserPanel.setPath(paths); }/* w w w .j a v a2s .co m*/ saveSourcePath(); } }