Example usage for javax.swing JFileChooser getSelectedFile

List of usage examples for javax.swing JFileChooser getSelectedFile

Introduction

In this page you can find the example usage for javax.swing JFileChooser getSelectedFile.

Prototype

public File getSelectedFile() 

Source Link

Document

Returns the selected file.

Usage

From source file:coreferenceresolver.gui.MainGUI.java

private void inputFileBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inputFileBtnActionPerformed
    JFileChooser inputFileChooser = new JFileChooser(defaulPath);
    inputFileChooser.setDialogTitle("Choose an input file");
    inputFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

    if (inputFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        inputFilePathTF.setText(inputFileChooser.getSelectedFile().getAbsolutePath());
    } else {/*  w w  w .  ja va2 s  . co  m*/
        noteTF.setText("No input file selected");
    }
}

From source file:coreferenceresolver.gui.MainGUI.java

private void markupFileBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_markupFileBtnActionPerformed
    JFileChooser inputFileChooser = new JFileChooser(defaulPath);
    inputFileChooser.setDialogTitle("Choose an markup file");
    inputFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

    if (inputFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        markupFilePathTF.setText(inputFileChooser.getSelectedFile().getAbsolutePath());
    } else {//from ww  w  .  jav a 2 s. c o  m
        noteTF.setText("No markup file selected");
    }
}

From source file:coreferenceresolver.gui.MainGUI.java

private void chooseTestingFileBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseTestingFileBtnActionPerformed
    JFileChooser inputFileChooser = new JFileChooser(defaulPath);
    inputFileChooser.setDialogTitle("Choose an testing file");
    inputFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

    if (inputFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        testingFilePathTF.setText(inputFileChooser.getSelectedFile().getAbsolutePath());
    } else {/*from w  w w  . ja v a  2  s  . c  o  m*/
        noteTF.setText("No testing file selected");
    }
}

From source file:org.martus.client.swingui.FxInSwingMainWindow.java

public File showFileOpenDialog(String title, File directory, Vector<FormatFilter> filters) {
    JFileChooser fileChooser = createFileChooser(title, directory, filters);

    int userResult = fileChooser.showOpenDialog(getCurrentActiveFrame().getSwingFrame());
    if (userResult != JFileChooser.APPROVE_OPTION)
        return null;

    return fileChooser.getSelectedFile();
}

From source file:coreferenceresolver.gui.MainGUI.java

private void chooseTrainingFileBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseTrainingFileBtnActionPerformed
    // TODO add your handling code here:
    JFileChooser inputFileChooser = new JFileChooser(defaulPath);
    inputFileChooser.setDialogTitle("Choose a training file");
    inputFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

    if (inputFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        trainingFilePathTF.setText(inputFileChooser.getSelectedFile().getAbsolutePath());
    } else {/*from   w w  w  . j a  v a2s.  co m*/
        noteTF.setText("No training file selected");
    }
}

From source file:com.mirth.connect.client.ui.MessageImportDialog.java

private void browseSelected() {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    if (userPreferences != null) {
        File currentDir = new File(userPreferences.get("currentDirectory", ""));

        if (currentDir.exists()) {
            chooser.setCurrentDirectory(currentDir);
        }/*  w  w  w. ja v  a 2  s.c o  m*/
    }

    if (chooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) {
        if (userPreferences != null) {
            userPreferences.put("currentDirectory", chooser.getCurrentDirectory().getPath());
        }

        fileTextField.setText(chooser.getSelectedFile().getAbsolutePath());
    }
}

From source file:userInterface.EnergySourceBoardSupervisor.ManageEnergyConsumptionsJPanel.java

private void uplaodBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uplaodBtnActionPerformed

    JFileChooser chooser = new JFileChooser();
    chooser.showOpenDialog(null);//from   www .ja  v a  2  s  .c  om
    File f = chooser.getSelectedFile();
    if (f != null) {
        path = f.getAbsolutePath();
        if (path != null) {
            attachmentpath_Txt.setText(path);
        }
    } else {
        JOptionPane.showMessageDialog(null, "File not selected", "WARNING", JOptionPane.WARNING_MESSAGE);
    }

}

From source file:AST.DesignPatternDetection.java

private void btPathFinderActionPerformed(ActionEvent e) {
    // TODO add your code here
    JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    f.showDialog(null, null);/*ww  w .ja v a2s  .  c o  m*/
    tfPath.setText(f.getSelectedFile().toString());

    vertices.clear();
    dugumler.clear();
    methods.clear();

    //System.out.println(f.getCurrentDirectory());
    //System.out.println(f.getSelectedFile());
}

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   ww w.  j a va2 s  .c om*/
    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);
}

From source file:it.staiger.jmeter.protocol.http.config.gui.DynamicFilePanel.java

/**
 * opens a dialog box to choose a file and returns selected file's
 * path./*from   w ww.java 2 s.co m*/
 *
 * @return a new File object
 */
private String browseAndGetFilePath() {
    String path = ""; //$NON-NLS-1$
    JFileChooser chooser = FileDialoger.promptToOpenFile();
    if (chooser != null) {
        File file = chooser.getSelectedFile();
        if (file != null) {
            path = file.getPath();
        }
    }
    return path;
}