List of usage examples for javax.swing JFileChooser setMultiSelectionEnabled
@BeanProperty(description = "Sets multiple file selection mode.") public void setMultiSelectionEnabled(boolean b)
From source file:com.stanley.captioner.MainFrame.java
private void addButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addButtonActionPerformed {//GEN-HEADEREND:event_addButtonActionPerformed JFileChooser fileChooser = new JFileChooser(); fileChooser.setMultiSelectionEnabled(true); FileNameExtensionFilter filter = new FileNameExtensionFilter("MP4 VIDEOS", "mp4", "mpeg"); fileChooser.setFileFilter(filter);/*from ww w.j a va 2 s. com*/ if (lastAddDirectory != null) { fileChooser.setCurrentDirectory(lastAddDirectory); } int returnValue = fileChooser.showOpenDialog(this); if (returnValue == JFileChooser.APPROVE_OPTION) { lastAddDirectory = fileChooser.getCurrentDirectory(); DefaultTableModel model = (DefaultTableModel) videoTable.getModel(); File files[] = fileChooser.getSelectedFiles(); for (File file : files) { boolean alreadyExists = false; for (int i = model.getRowCount() - 1; i >= 0; i--) { String path = (String) model.getValueAt(i, 0); if (file.getAbsolutePath().equals(path)) { alreadyExists = true; } } if (!alreadyExists) { model.addRow(getVideoInfo(file)); } } } }
From source file:TextFileHandler.java
public File[] openFiles(String title) { File[] result = null;//from w w w. j a v a2 s .c o m JFileChooser chooser = new JFileChooser(new File(".")); if (title != null) chooser.setDialogTitle(title); chooser.setMultiSelectionEnabled(true); int retVal = chooser.showOpenDialog(null); if (retVal == JFileChooser.APPROVE_OPTION) { result = chooser.getSelectedFiles(); } return result; }
From source file:net.sf.keystore_explorer.gui.actions.SignCsrAction.java
private File chooseCsrFile() { JFileChooser chooser = FileChooserFactory.getCsrFileChooser(); chooser.setCurrentDirectory(CurrentDirectory.get()); chooser.setDialogTitle(res.getString("SignCsrAction.ChooseCsr.Title")); chooser.setMultiSelectionEnabled(false); int rtnValue = chooser.showDialog(frame, res.getString("SignCsrAction.ChooseCsr.button")); if (rtnValue == JFileChooser.APPROVE_OPTION) { File importFile = chooser.getSelectedFile(); CurrentDirectory.updateForFile(importFile); return importFile; }/*w w w . ja va 2 s. c o m*/ return null; }
From source file:net.sf.keystore_explorer.gui.actions.ExamineFileAction.java
private File chooseFile() { JFileChooser chooser = FileChooserFactory.getCertFileChooser(); chooser.setCurrentDirectory(CurrentDirectory.get()); chooser.setDialogTitle(res.getString("ExamineFileAction.ExamineFile.Title")); chooser.setMultiSelectionEnabled(false); int rtnValue = chooser.showDialog(frame, res.getString("ExamineFileAction.ExamineFile.button")); if (rtnValue == JFileChooser.APPROVE_OPTION) { File openFile = chooser.getSelectedFile(); CurrentDirectory.updateForFile(openFile); return openFile; }//from www . j a v a2 s . co m return null; }
From source file:PeerPanel.java
private void saveLocationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveLocationButtonActionPerformed JFileChooser jfc = new JFileChooser(); jfc.setCurrentDirectory(saveDirectory); jfc.setMultiSelectionEnabled(false); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { saveDirectory = jfc.getSelectedFile(); saveLocationDisplay.setText(saveDirectory.getAbsolutePath()); }/*from w w w.j av a2s. c o m*/ }
From source file:com.simplexrepaginator.RepaginateFrame.java
protected JButton creatOutputButton() { JButton b = new JButton("Click or drag to set output file", PDF_1234); b.setHorizontalTextPosition(SwingConstants.LEFT); b.setIconTextGap(25);/* w w w . ja v a 2s.c om*/ b.setTransferHandler(new OutputButtonTransferHandler()); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); if (chooser.showOpenDialog(RepaginateFrame.this) != JFileChooser.APPROVE_OPTION) return; repaginator.setOutputFiles(Arrays.asList(chooser.getSelectedFiles())); output.setText("<html><center>" + StringUtils.join(repaginator.getOutputFiles(), "<br>")); } }); return b; }
From source file:com.simplexrepaginator.RepaginateFrame.java
protected JButton createInputButton() { JButton b = new JButton("Click or drag to set input files", PDF_1342); b.setHorizontalTextPosition(SwingConstants.RIGHT); b.setIconTextGap(25);//from w w w . ja va 2s .com b.setTransferHandler(new InputButtonTransferHandler()); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); if (chooser.showOpenDialog(RepaginateFrame.this) != JFileChooser.APPROVE_OPTION) return; setInput(Arrays.asList(chooser.getSelectedFiles())); if (JOptionPane.showConfirmDialog(RepaginateFrame.this, "Use input paths as output paths?", "Use Input As Output?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { setOutput(new ArrayList<File>(repaginator.getInputFiles())); } } }); return b; }
From source file:edu.clemson.lph.civet.addons.VspsCviFile.java
public void importVspsFile(Window parent) { String sVspsDir = CivetConfig.getVspsDirPath(); File fDir = new File(sVspsDir); JFileChooser open = new JFileChooser(fDir); Action details = open.getActionMap().get("viewTypeDetails"); details.actionPerformed(null);// w w w.j a v a2 s .co m open.setDialogTitle("Civet: Open PDF File"); open.setFileSelectionMode(JFileChooser.FILES_ONLY); open.setFileFilter(new FileNameExtensionFilter("CSV Files", "csv")); open.setMultiSelectionEnabled(false); int resultOfFileSelect = open.showOpenDialog(parent); if (resultOfFileSelect == JFileChooser.APPROVE_OPTION) { File fIn = open.getSelectedFile(); saveme(parent, fIn); // vsps.printme(); } }
From source file:org.jax.maanova.plot.SaveChartAction.java
/** * {@inheritDoc}/*from ww w. j av a2 s .c om*/ */ public void actionPerformed(ActionEvent e) { JFreeChart myChart = this.chart; Dimension mySize = this.size; if (myChart == null || mySize == null) { LOG.severe("Failed to save graph image because of a null value"); MessageDialogUtilities.errorLater(Maanova.getInstance().getApplicationFrame(), "Internal error: Failed to save graph image.", "Image Save Failed"); } else { // use the remembered starting dir MaanovaApplicationConfigurationManager configurationManager = MaanovaApplicationConfigurationManager .getInstance(); JMaanovaApplicationState applicationState = configurationManager.getApplicationState(); FileType rememberedJaxbImageDir = applicationState.getRecentImageExportDirectory(); File rememberedImageDir = null; if (rememberedJaxbImageDir != null && rememberedJaxbImageDir.getFileName() != null) { rememberedImageDir = new File(rememberedJaxbImageDir.getFileName()); } // select the image file to save JFileChooser fileChooser = new JFileChooser(rememberedImageDir); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setApproveButtonText("Save Graph"); fileChooser.setDialogTitle("Save Graph as Image"); fileChooser.setMultiSelectionEnabled(false); fileChooser.addChoosableFileFilter(PngFileFilter.getInstance()); fileChooser.setFileFilter(PngFileFilter.getInstance()); int response = fileChooser.showSaveDialog(Maanova.getInstance().getApplicationFrame()); if (response == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); // tack on the extension if there isn't one // already if (!PngFileFilter.getInstance().accept(selectedFile)) { String newFileName = selectedFile.getName() + "." + PngFileFilter.PNG_EXTENSION; selectedFile = new File(selectedFile.getParentFile(), newFileName); } if (selectedFile.exists()) { // ask the user if they're sure they want to overwrite String message = "Exporting the graph image to " + selectedFile.getAbsolutePath() + " will overwrite an " + " existing file. Would you like to continue anyway?"; if (LOG.isLoggable(Level.FINE)) { LOG.fine(message); } boolean overwriteOk = MessageDialogUtilities .confirmOverwrite(Maanova.getInstance().getApplicationFrame(), selectedFile); if (!overwriteOk) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("overwrite canceled"); } return; } } try { ChartUtilities.saveChartAsPNG(selectedFile, myChart, mySize.width, mySize.height); File parentDir = selectedFile.getParentFile(); if (parentDir != null) { // update the "recent image directory" ObjectFactory objectFactory = new ObjectFactory(); FileType latestJaxbImageDir = objectFactory.createFileType(); latestJaxbImageDir.setFileName(parentDir.getAbsolutePath()); applicationState.setRecentImageExportDirectory(latestJaxbImageDir); } } catch (Exception ex) { LOG.log(Level.SEVERE, "failed to save graph image", ex); } } } }
From source file:de.uka.ilkd.key.dl.gui.initialdialog.gui.ToolInstaller.java
public void install(JComponent parent, Window dialog) { final File installDirectory; switch (OSInfosDefault.INSTANCE.getOs()) { case OSX://w w w . ja va 2 s . c o m System.setProperty("apple.awt.fileDialogForDirectories", "true"); FileDialog d = new FileDialog(Frame.getFrames()[0], "Choose directory for installation of " + toolName, FileDialog.LOAD); d.setVisible(true); System.setProperty("apple.awt.fileDialogForDirectories", "false"); if (d.getFile() != null) { installDirectory = new File(d.getDirectory(), d.getFile()); } else { installDirectory = null; } break; default: final JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Choose directory for installation of " + toolName); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setApproveButtonText("Install " + toolName + " here"); int result = chooser.showDialog(parent, "Install " + toolName + " here"); if (result == JFileChooser.APPROVE_OPTION) { installDirectory = chooser.getSelectedFile(); } else { installDirectory = null; } } if (installDirectory != null) { try { final File tmp = File.createTempFile("keymaeraDownload", "." + ft.toString().toLowerCase()); final FileInfo info = new FileInfo(url, tmp.getName(), false); final DownloadManager dlm = new DownloadManager(); ProgressBarWindow pbw = new ProgressBarWindow(parent, installDirectory, tmp, ft, ps, dialog); dlm.addListener(pbw); Runnable down = new Runnable() { @Override public void run() { dlm.downloadAll(new FileInfo[] { info }, 2000, tmp.getParentFile().getAbsolutePath(), true); } }; Thread thread = new Thread(down); thread.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }