List of usage examples for javax.swing JFileChooser setCurrentDirectory
@BeanProperty(preferred = true, description = "The directory that the JFileChooser is showing files of.") public void setCurrentDirectory(File dir)
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);// www .j a v a 2s . c om 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:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void saveTSV() { JFileChooser chooser = new JFileChooser("Save evaluation result as TSV"); chooser.setCurrentDirectory(frame.defaultDirectory); int returnVal = chooser.showSaveDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile().exists() && (JOptionPane.showConfirmDialog(frame, "File already exists. Overwrite?") != JOptionPane.YES_OPTION)) { return; }//from w ww.j av a 2 s. c o m frame.saveTSV(chooser.getSelectedFile()); } }
From source file:de.ist.clonto.Ontogui.java
private void loadQuery(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_loadQuery JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir") + "/sparql")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { queryPath = fc.getSelectedFile().toPath(); smellNameField.setText(fc.getSelectedFile().getName()); } else {//www .ja va 2s . co m JOptionPane.showMessageDialog(this, "Loading query failed"); } }
From source file:de.ist.clonto.Ontogui.java
private void loadOntology(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_loadOntology if (null != dataset) { dataset.end();//from ww w .ja va 2s .c o m } JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { dataset = TDBFactory.createDataset(fc.getSelectedFile().toString()); ontologyNameField.setText(fc.getSelectedFile().getName()); ontoPath = fc.getSelectedFile().toPath(); } else { JOptionPane.showMessageDialog(this, "Loading ontology failed"); } }
From source file:de.ist.clonto.Ontogui.java
private void backupOntologyButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_backupOntologyButtonActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try {// w w w . j av a2 s . co m FileUtils.cleanDirectory(fc.getSelectedFile()); FileUtils.copyDirectory(ontoPath.toFile(), fc.getSelectedFile()); } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Loading ontology failed"); } JOptionPane.showMessageDialog(this, "Created Backup files!"); } else { JOptionPane.showMessageDialog(this, "Loading ontology failed"); } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void saveXML() { JFileChooser chooser = new JFileChooser("Save evaluation result as alignment XML"); chooser.setCurrentDirectory(frame.defaultDirectory); int returnVal = chooser.showSaveDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile().exists() && (JOptionPane.showConfirmDialog(frame, "File already exists. Overwrite?") != JOptionPane.YES_OPTION)) { return; }/*ww w. ja v a 2s . c o m*/ try { frame.saveXML(chooser.getSelectedFile(), SaveXMLMode.SAVE_EVERYTHING); } catch (JDOMException | IOException e) { JOptionPane.showConfirmDialog(frame, e, "Error saving XML", JOptionPane.ERROR_MESSAGE); } } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void loadPositiveNegativeNT() throws IOException { JFileChooser chooser = new JFileChooser("Load multiple nt files. Please choose a directory"); chooser.setCurrentDirectory(frame.defaultDirectory); if (geoFile != null) { chooser.setCurrentDirectory(geoFile); }//from w w w. j av a2s. c o m chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); int returnVal = chooser.showSaveDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.print("Loading..."); frame.loadPositiveNegativeNT(chooser.getSelectedFile()); System.out.println("loading finished."); } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void savePositiveNegativeNT() throws IOException { JFileChooser chooser = new JFileChooser("Save as multiple nt files. Please choose a directory"); chooser.setCurrentDirectory(frame.defaultDirectory); if (geoFile != null) { chooser.setCurrentDirectory(geoFile); }/*from ww w.j a v a 2 s. c o m*/ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); int returnVal = chooser.showSaveDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { frame.savePositiveNegativeNT(chooser.getSelectedFile()); } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void saveReference(boolean mustSupportEvaluation, boolean includeEvaluation) throws FileNotFoundException { Set<ReferenceFormat> formats = mustSupportEvaluation ? ReferenceFormats.REFERENCE_FORMATS.evaluationIncludingFormats : ReferenceFormats.REFERENCE_FORMATS.formats; formats.retainAll(ReferenceFormats.REFERENCE_FORMATS.writeableFormats); ReferenceFormat format = formatChooser(formats); if (format == null) { return;//ww w. j av a2s . c om } JFileChooser chooser = new JFileChooser("Save reference. Please choose a file."); chooser.setCurrentDirectory(frame.defaultDirectory); chooser.setFileSelectionMode( format.readsDirectory() ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY); if (format.getFileExtension() != null) { chooser.addChoosableFileFilter( new FilesystemFilter(format.getFileExtension(), format.getDescription())); } else { chooser.setAcceptAllFileFilterUsed(true); } int returnVal = chooser.showSaveDialog(frame); if (returnVal != JFileChooser.APPROVE_OPTION) return; System.out.print("Saving..."); format.writeReference(frame.reference, chooser.getSelectedFile(), includeEvaluation); //frame.loadPositiveNegativeNT(chooser.getSelectedFile()); System.out.println("saving finished."); }
From source file:com.dfki.av.sudplan.vis.wiz.DataSourceSelectionPanel.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed JFileChooser jfc = new JFileChooser(); jfc.addChoosableFileFilter(new FileNameExtensionFilter("ESRI Shapfile (*.shp)", "shp", "Shp", "SHP")); jfc.addChoosableFileFilter(new FileNameExtensionFilter("Zip file (*.zip)", "zip", "ZIP", "Zip")); XMLConfiguration xmlConfig = Configuration.getXMLConfiguration(); String path = xmlConfig.getString("sudplan3D.working.dir"); File dir;//from w ww .j a va 2 s . com if (path != null) { dir = new File(path); if (dir.exists()) { jfc.setCurrentDirectory(dir); } } int retValue = jfc.showOpenDialog(this); if (retValue == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); if (f != null) { jLabel1.setText(f.getAbsolutePath()); file = f; } } else { if (log.isDebugEnabled()) { log.debug("No shp file selected."); } } dir = jfc.getCurrentDirectory(); path = dir.getAbsolutePath(); xmlConfig.setProperty("sudplan3D.working.dir", path); }