List of usage examples for javax.swing JFileChooser DIRECTORIES_ONLY
int DIRECTORIES_ONLY
To view the source code for javax.swing JFileChooser DIRECTORIES_ONLY.
Click Source Link
From source file:oct.analysis.application.OCTAnalysisUI.java
private void exportAnalysisResultsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportAnalysisResultsMenuItemActionPerformed fc.resetChoosableFileFilters();/*from w ww . ja v a 2s . c om*/ fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fc.getSelectedFile() != null && fc.getSelectedFile().isFile()) { fc.setCurrentDirectory(fc.getSelectedFile().getParentFile()); } int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File saveDir = fc.getSelectedFile(); try { AnalysisSaver.exportAnalysisData(saveDir); } catch (IOException ex) { Logger.getLogger(OCTAnalysisUI.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:marytts.tools.redstart.AdminWindow.java
private void jMenuItem_OpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_OpenActionPerformed // Allow user to choose a different voice (prompt set) without exiting the tool // Create a file chooser final JFileChooser openDialog = new JFileChooser(); // Set the current directory to the voice currently in use openDialog.setCurrentDirectory(getVoiceFolderPath()); openDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = openDialog.showDialog(AdminWindow.this, "Open Voice"); if (result == JFileChooser.APPROVE_OPTION) { File voice = openDialog.getSelectedFile(); setVoiceFolderPath(voice); // Set to the selected the voice folder path Test.output("Open voice: " + voice); setupVoice();/*from w w w . jav a 2 s .com*/ } else { Test.output("Open command cancelled."); } }
From source file:com.pianobakery.complsa.MainGui.java
public void chooseNewProjectFolder() { try {/*from w w w . j a va 2 s . c o m*/ JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(openFolder); //chooser.setCurrentDirectory(new java.io.File(System.getProperty("user.home"))); chooser.setDialogTitle("Choose Folder"); chooser.setFileHidingEnabled(Boolean.TRUE); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); chooser.setAcceptAllFileFilterUsed(false); chooser.setApproveButtonText("Choose"); int whatChoose = chooser.showOpenDialog(null); if (whatChoose == JFileChooser.APPROVE_OPTION) { String text = chooser.getSelectedFile().toString(); wDirText.setText(text); wDir = chooser.getSelectedFile(); logger.debug("WDir is: " + wDir.toString()); logger.debug("getCurrentDirectory(): " + chooser.getCurrentDirectory()); logger.debug("getSelectedFile() : " + chooser.getSelectedFile()); enableUIElements(true); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Falsche Eingabe"); } }
From source file:org.biojava.bio.view.MotifAnalyzer.java
public void runMethod(MotifFinder method) { final JFileChooser fc = new JFileChooser(); fc.setFileFilter(new Filter("fasta")); fc.setDialogTitle("Select Sequence File (in FASTA format)"); int returnVal = JFileChooser.CANCEL_OPTION; if (datasetComboBox.getSelectedItem().equals(Dataset.unknown)) returnVal = fc.showOpenDialog(MotifAnalyzer.this.mainFrame); if (!datasetComboBox.getSelectedItem().equals(Dataset.unknown) || (returnVal == JFileChooser.APPROVE_OPTION)) { try {//from w w w . j a va 2 s. com final JFileChooser readDirectory = new JFileChooser(); readDirectory.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (readDirectory.showOpenDialog(MotifAnalyzer.this.mainFrame) == JFileChooser.APPROVE_OPTION) { Dataset dataset = (Dataset) datasetComboBox.getSelectedItem(); int type = datasetTypeComboBox.getSelectedIndex(); String fileName = (returnVal == JFileChooser.APPROVE_OPTION) ? fc.getSelectedFile().getCanonicalPath() : TompaDataset.getDatasetSequenceFileName(dataset); int i = Integer.parseInt(numOfMotifs.getText()); int w = Integer.parseInt(motifWidth.getText()); int t = Integer.parseInt(numOfTrials.getText()); OrganismCode organism = OrganismCode.getOrganism(organismType.getSelectedIndex()); log.info("Runninf method: " + method.name()); log.info("FileName: " + fileName); log.info("Outputfile: " + readDirectory.getSelectedFile().getCanonicalPath()); log.info("Dataset: " + dataset.name()); log.info("DatasetType: " + type); controller.runAndEvaluate(method, fileName, i, w, t, organism, dataset, readDirectory.getSelectedFile().getCanonicalPath()); displayCharts(); } } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(mainFrame, "An Error occured", "Error", JOptionPane.ERROR_MESSAGE); } } }
From source file:neembuu.uploader.NeembuuUploader.java
private void selectFolderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectFolderButtonActionPerformed //Open up the Open File dialog //If the user clicks cancel or close, do not continue. f.setMultiSelectionEnabled(false);/*from w w w . j a v a2 s . c o m*/ f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); f.setAcceptAllFileFilterUsed(false); if (f.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) { return; } File folder = f.getSelectedFile(); //getSelectedFiles() returns as File array. //We need ArrayList for efficiency. So convert array to ArrayList this.files = new ArrayList<File>( FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)); //Same stuff as in FileDrop code in constructor if (files.size() == 1) { inputFileTextField.setText(files.get(0) + ""); } else { inputFileTextField.setText(files.size() + " " + Translation.T().nfilesselected()); } NULogger.getLogger().info("Files selected"); }
From source file:grupob.TipoProceso.java
private void seleccionarHuellasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_seleccionarHuellasActionPerformed JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogTitle("Seleccionar Carpeta"); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); if (!Utils.validarRutaImagenHuella(selectedFile.getAbsolutePath(), 1)) { JOptionPane.showMessageDialog(null, "Debe seleccionar una carpeta con archivos JPG con la cantidad de registros de votantes exacta."); } else {/*from ww w.j a v a 2 s. com*/ textConfHuellas.setText("" + selectedFile); } // Recorte.rutaHuella=""+selectedFile; } }
From source file:fur.shadowdrake.minecraft.InstallPanel.java
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed JFileChooser fc = new JFileChooser(new File(dirBox.getText())); fc.setFileHidingEnabled(false);/*from ww w . j a v a 2 s . c o m*/ fc.setDialogTitle("Select directory"); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { dirBox.setText(fc.getSelectedFile().toString()); } }
From source file:com.pianobakery.complsa.MainGui.java
public File chooseAddCorpusFolder() { try {/*from www . ja v a 2 s. co m*/ JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(System.getProperty("user.home"))); chooser.setDialogTitle("Create Working Folder"); chooser.setFileHidingEnabled(Boolean.TRUE); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); chooser.setAcceptAllFileFilterUsed(false); int whatChoose = chooser.showOpenDialog(null); File selected; if (whatChoose == JFileChooser.APPROVE_OPTION) { selected = chooser.getSelectedFile(); logger.debug("AddCorpDir is: " + selected.toString()); logger.debug("getCurrentDirectory(): " + chooser.getCurrentDirectory()); logger.debug("getSelectedFile() : " + chooser.getSelectedFile()); enableUIElements(true); return selected; } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Falsche Eingabe"); } return null; }
From source file:grupob.TipoProceso.java
private void seleccionarFirmasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_seleccionarFirmasActionPerformed JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogTitle("Seleccionar Carpeta"); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); if (!Utils.validarRutaImagenHuella(selectedFile.getAbsolutePath(), 1)) { JOptionPane.showMessageDialog(null, "Debe seleccionar una carpeta con archivos JPG con la cantidad de registros de votantes exacta."); } else {/* www . j a v a 2s . c om*/ textConfFirmas.setText("" + selectedFile); } // Recorte.rutaFirma=""+selectedFile; } }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override public void doExport(IExporter exporter) throws IOException { boolean isMultipleSeries = getDataset().getSeriesCount() > 1; JFileChooser fileChooser = new JFileChooser(); String currentDirectory = System.getProperty(StaticValues.SYSTEM_SAVE_PATH_LABEL); if (currentDirectory != null) { File savePath = new File(currentDirectory); if (savePath.exists() && savePath.isDirectory()) { fileChooser.setCurrentDirectory(savePath); }/* w w w.j a v a 2s . c om*/ } String fileExtension = exporter.getExtensionName(); ExtensionFileFilter extensionFilter = new ExtensionFileFilter(exporter.toString(), "." + fileExtension); fileChooser.addChoosableFileFilter(extensionFilter); if (isMultipleSeries) { fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } int option = fileChooser.showSaveDialog(this); if (option == JFileChooser.APPROVE_OPTION) { String filename = fileChooser.getSelectedFile().getPath(); int confirm = JOptionPane.YES_OPTION; File selectedFile; if (isMultipleSeries) { selectedFile = new File(filename); if (!selectedFile.exists()) { selectedFile.mkdirs(); } exporter.export(selectedFile, getDataset()); System.setProperty(StaticValues.SYSTEM_SAVE_PATH_LABEL, fileChooser.getSelectedFile().getAbsolutePath()); } else { if (!filename.toLowerCase().endsWith("." + fileExtension)) { filename = filename + "." + fileExtension; } selectedFile = new File(filename); if (selectedFile.exists()) { confirm = JOptionPane.showConfirmDialog(this, selectedFile.getName() + " exists, overwrite?", "Confirm Overwriting", JOptionPane.YES_NO_OPTION); } else { selectedFile.createNewFile(); } if (confirm == JOptionPane.YES_OPTION) { exporter.export(selectedFile, getDataset()); System.setProperty(StaticValues.SYSTEM_SAVE_PATH_LABEL, fileChooser.getSelectedFile().getParent()); } } } }