List of usage examples for javax.swing JFileChooser setFileSelectionMode
@BeanProperty(preferred = true, enumerationValues = { "JFileChooser.FILES_ONLY", "JFileChooser.DIRECTORIES_ONLY", "JFileChooser.FILES_AND_DIRECTORIES" }, description = "Sets the types of files that the JFileChooser can choose.") public void setFileSelectionMode(int mode)
JFileChooser
to allow the user to just select files, just select directories, or select both files and directories. From source file:org.pgptool.gui.ui.tools.browsefs.SaveFileChooserDialog.java
private JFileChooser prepareFileChooser() { JFileChooser ofd = new JFileChooser(); ofd.setFileSelectionMode(JFileChooser.FILES_ONLY); ofd.setMultiSelectionEnabled(false); ofd.setDialogTitle(Messages.get(dialogTitleCode)); ofd.setApproveButtonText(Messages.get(approvalButtonTextCode)); onFileChooserPostConstrct(ofd);//from w w w . j ava2 s .co m suggestTarget(ofd); return ofd; }
From source file:kuvalataaja.user_interface.GUI.java
/** * Select a directory and pass it to Main.run *//*from w w w . ja v a 2 s .co m*/ public void runTheProgram() { String separatorString = openSettings(); char separator = separatorString.charAt(0); JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.showDialog(this, "Please select your Music folder"); File f = new File(chooser.getSelectedFile().getPath()); textArea.setText("Working..."); String[] result = kuvalataaja.kuvalataaja.Main.run(f, separator); //Shows a list of which album covers were fetched showResult(result); }
From source file:de.erdesignerng.visual.editor.openxavaexport.OpenXavaExportEditor.java
private void commandChooseSrcDirectory() { JFileChooser theChooser = new JFileChooser(); theChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (theChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { File theBaseDirectory = theChooser.getSelectedFile(); editingView.getSrcDirectory().setText(theBaseDirectory.toString()); }//from w w w . j a v a 2 s . c o m }
From source file:com.ev.export.AnnualPDFExporter.java
@Override public String chooseFile() throws IOException { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.showSaveDialog(MainFrame.getInstance()); File selectedFile = jfc.getSelectedFile(); if (selectedFile == null) { throw new IOException("No file chosen."); }/* w w w . j a va2 s . c om*/ return selectedFile.getCanonicalPath() + File.separator + year + PDF_SUFFIX; }
From source file:com.moneydance.modules.features.importlist.io.DefaultDirectoryChooser.java
@Override void chooseBaseDirectory() { final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle(this.getLocalizable().getDirectoryChooserTitle()); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // disable the "All files" option. fileChooser.setAcceptAllFileFilterUsed(false); try {//from ww w.j a va 2s . c o m fileChooser.setCurrentDirectory(FileUtils.getUserDirectory()); } catch (SecurityException e) { LOG.log(Level.WARNING, e.getMessage(), e); } if (this.getBaseDirectory() != null) { final File parentDirectory = this.getBaseDirectory().getParentFile(); fileChooser.setCurrentDirectory(parentDirectory); } if (fileChooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) { return; } this.getPrefs().setBaseDirectory(fileChooser.getSelectedFile().getAbsolutePath()); LOG.info(String.format("Base directory is %s", this.getPrefs().getBaseDirectory())); }
From source file:CompareFiles.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String userDir = System.getProperty("user.home"); JFileChooser folder = new JFileChooser(userDir + "/Desktop"); folder.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("Excel Files (*.xls)", "xls"); folder.setFileFilter(xmlfilter);//from w w w. jav a2 s . com // folder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnvalue = folder.showSaveDialog(this); File myfolder = null; if (returnvalue == JFileChooser.APPROVE_OPTION) { myfolder = folder.getSelectedFile(); // System.out.println(myfolder); } if (myfolder != null) { JOptionPane.showMessageDialog(null, "The current choosen file directory is : " + myfolder); jLabel1.setText(myfolder.toString()); } }
From source file:net.mitnet.tools.pdf.book.publisher.ui.gui.BaseBookPublisherGUI.java
protected void browseDir(JTextField dirField) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fileChooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); String selectedFilePath = selectedFile.getAbsolutePath(); dirField.setText(selectedFilePath); }/*from ww w .java 2 s . c o m*/ }
From source file:net.mitnet.tools.pdf.book.publisher.ui.gui.BaseBookPublisherGUI.java
protected void browseFile(JTextField dirField) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = fileChooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); String selectedFilePath = selectedFile.getAbsolutePath(); dirField.setText(selectedFilePath); }/*w w w .ja v a 2 s . c o m*/ }
From source file:com.github.cmisbox.ui.UI.java
public File getWatchFolder() { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); chooser.showOpenDialog(null);//w ww.ja v a 2 s . c om return chooser.getSelectedFile(); }
From source file:edu.umich.robot.ViewerApplication.java
private Config promptForConfig() { JFileChooser fc = new JFileChooser("config"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); FileFilter filter = new FileNameExtensionFilter("Text Config File", "txt"); fc.setFileFilter(filter);/*from ww w.j av a 2 s. com*/ fc.setMultiSelectionEnabled(false); int ret = fc.showOpenDialog(frame); if (ret == JFileChooser.APPROVE_OPTION) { try { return new ConfigFile(fc.getSelectedFile().getAbsolutePath()); } catch (IOException e) { logger.error(e.getMessage()); } } return null; }