Example usage for javax.swing JFileChooser setCurrentDirectory

List of usage examples for javax.swing JFileChooser setCurrentDirectory

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The directory that the JFileChooser is showing files of.")
public void setCurrentDirectory(File dir) 

Source Link

Document

Sets the current directory.

Usage

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairOpenSsl.java

private void certificateBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getCertFileChooser();

    File currentFile = new File(jtfCertificatePath.getText());

    if ((currentFile.getParentFile() != null) && (currentFile.getParentFile().exists())) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
    } else {/*from   ww w  . j av a2  s . co  m*/
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DImportKeyPairOpenSsl.ChooseCertificate.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this,
            res.getString("DImportKeyPairOpenSsl.CertificateFileChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfCertificatePath.setText(chosenFile.toString());
        jtfCertificatePath.setCaretPosition(0);
    }
}

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPkcs8.java

private void privateKeyBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getPkcs8FileChooser();

    File currentFile = new File(jtfPrivateKeyPath.getText());

    if ((currentFile.getParentFile() != null) && (currentFile.getParentFile().exists())) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
    } else {//from w w  w . ja  va 2  s .co m
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DImportKeyPairPkcs8.ChoosePrivateKey.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this, res.getString("DImportKeyPairPkcs8.PrivateKeyFileChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfPrivateKeyPath.setText(chosenFile.toString());
        jtfPrivateKeyPath.setCaretPosition(0);
    }
}

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPkcs8.java

private void certificateBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getCertFileChooser();

    File currentFile = new File(jtfCertificatePath.getText());

    if ((currentFile.getParentFile() != null) && (currentFile.getParentFile().exists())) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
    } else {//from  w  w w.ja va 2  s.  c om
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DImportKeyPairPkcs8.ChooseCertificate.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this, res.getString("DImportKeyPairPkcs8.CertificateFileChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfCertificatePath.setText(chosenFile.toString());
        jtfCertificatePath.setCaretPosition(0);
    }
}

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPvk.java

private void privateKeyBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getPvkFileChooser();

    File currentFile = new File(jtfPrivateKeyPath.getText());

    if ((currentFile.getParentFile() != null) && (currentFile.getParentFile().exists())) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
    } else {/*from   w w w .j  av  a 2s.  c om*/
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DImportKeyPairPvk.ChoosePrivateKey.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this, res.getString("DImportKeyPairPvk.PrivateKeyFileChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfPrivateKeyPath.setText(chosenFile.toString());
        jtfPrivateKeyPath.setCaretPosition(0);
    }
}

From source file:org.kse.gui.dialogs.importexport.DImportKeyPairPvk.java

private void certificateBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getCertFileChooser();

    File currentFile = new File(jtfCertificatePath.getText());

    if ((currentFile.getParentFile() != null) && (currentFile.getParentFile().exists())) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
    } else {/*from w  ww.ja va 2 s . c  om*/
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DImportKeyPairPvk.ChooseCertificate.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this, res.getString("DImportKeyPairPvk.CertificateFileChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfCertificatePath.setText(chosenFile.toString());
        jtfCertificatePath.setCaretPosition(0);
    }
}

From source file:org.kse.gui.dialogs.sign.DSignJar.java

private void inputJarBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getArchiveFileChooser();

    File currentFile = new File(jtfInputJar.getText().trim());

    if (currentFile.getParentFile() != null && currentFile.getParentFile().exists()) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
        chooser.setSelectedFile(currentFile);
    } else {/*from  ww w  . ja  v a 2s  . c o  m*/
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DSignJar.ChooseInputJar.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this, res.getString("DSignJar.InputJarChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfInputJar.setText(chosenFile.toString());
        jtfInputJar.setCaretPosition(0);
        populateOutputJarFileName(chosenFile);
    }
}

From source file:org.kse.gui.dialogs.sign.DSignJar.java

private void outputJarBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getArchiveFileChooser();

    File currentFile = new File(jtfOutputJar.getText());

    if (currentFile.getParentFile() != null && currentFile.getParentFile().exists()) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
        chooser.setSelectedFile(currentFile);
    } else {/*from  w  w  w  .j a  v a  2s  .  c  om*/
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DSignJar.ChooseOutputJar.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = JavaFXFileChooser.isFxAvailable() ? chooser.showSaveDialog(this)
            : chooser.showDialog(this, res.getString("DSignJar.OutputJarChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfOutputJar.setText(chosenFile.toString());
        jtfOutputJar.setCaretPosition(0);
    }
}

From source file:org.kse.gui.dialogs.sign.DSignMidlet.java

private void inputJadBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getJadFileChooser();

    File currentFile = new File(jtfInputJad.getText());

    if (currentFile.getParentFile() != null && currentFile.getParentFile().exists()) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
        chooser.setSelectedFile(currentFile);
    } else {//from  w w w  .j ava2 s  . c  om
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DSignMidlet.ChooseInputJad.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this, res.getString("DSignMidlet.InputJadChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfInputJad.setText(chosenFile.toString());
        jtfInputJad.setCaretPosition(0);
        populateOutputJadFileName(chosenFile);
    }
}

From source file:org.kse.gui.dialogs.sign.DSignMidlet.java

private void outputJadBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getJadFileChooser();

    File currentFile = new File(jtfOutputJad.getText());

    if (currentFile.getParentFile() != null && currentFile.getParentFile().exists()) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
        chooser.setSelectedFile(currentFile);
    } else {/*  w  ww.ja v  a  2 s  . c  o m*/
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DSignMidlet.ChooseOutputJad.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = JavaFXFileChooser.isFxAvailable() ? chooser.showSaveDialog(this)
            : chooser.showDialog(this, res.getString("DSignMidlet.OutputJadChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfOutputJad.setText(chosenFile.toString());
        jtfOutputJad.setCaretPosition(0);
    }
}

From source file:org.kse.gui.dialogs.sign.DSignMidlet.java

private void jarBrowsePressed() {
    JFileChooser chooser = FileChooserFactory.getArchiveFileChooser();

    File currentFile = new File(jtfJar.getText());

    if (currentFile.getParentFile() != null && currentFile.getParentFile().exists()) {
        chooser.setCurrentDirectory(currentFile.getParentFile());
    } else {/*  w  w w .  j a v  a 2s.  co m*/
        chooser.setCurrentDirectory(CurrentDirectory.get());
    }

    chooser.setDialogTitle(res.getString("DSignMidlet.ChooseJar.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this, res.getString("DSignMidlet.JarChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(chosenFile);
        jtfJar.setText(chosenFile.toString());
        jtfJar.setCaretPosition(0);
    }
}