Example usage for javax.swing JFileChooser setDialogTitle

List of usage examples for javax.swing JFileChooser setDialogTitle

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The title of the JFileChooser dialog window.")
public void setDialogTitle(String dialogTitle) 

Source Link

Document

Sets the string that goes in the JFileChooser window's title bar.

Usage

From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java

private JFileChooser createFileChooser() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setDialogTitle("Select directory to output to");
    fileChooser.setApproveButtonText("Output here");

    return fileChooser;
}

From source file:org.isatools.isacreator.spreadsheet.SpreadsheetFunctions.java

protected void resolveFileLocations() {
    int[] selectedRows = spreadsheet.getTable().getSelectedRows();
    int selectedColumn = spreadsheet.getTable().getSelectedColumn();

    JFileChooser fileLocChooser = new JFileChooser();
    fileLocChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    fileLocChooser.setDialogTitle("Select directory to search through");
    fileLocChooser.setApproveButtonText("Select directory");

    if (fileLocChooser.showOpenDialog(spreadsheet) == JFileChooser.APPROVE_OPTION) {
        File dir = fileLocChooser.getSelectedFile();

        String[] files = new String[selectedRows.length];

        for (int row = 0; row < selectedRows.length; row++) {
            files[row] = spreadsheet.getTable().getValueAt(selectedRows[row], selectedColumn).toString();
        }//  w ww.j  ava2  s.  c om

        FileLocationMapperUtil fmu = new FileLocationMapperUtil();
        Map<String, String> result = fmu.findProperFileLocations(files, dir);

        for (int selectedRow : selectedRows) {
            String candidateVal = spreadsheet.getTable().getValueAt(selectedRow, selectedColumn).toString();
            if (result.keySet().contains(candidateVal)) {
                spreadsheet.getTable().setValueAt(result.get(candidateVal), selectedRow, selectedColumn);
            }
        }
    }

    // otherwise, do nothing
}

From source file:org.jab.docsearch.DocSearch.java

private void doSave() {
    setStatus(I18n.getString("tooltip.save"));

    // defaultSaveFolder
    JFileChooser fds = new JFileChooser();
    fds.setDialogTitle(I18n.getString("windowtitle.save"));

    String saveName;// w w  w . jav  a2s  .co m
    if (curPage.equals("results")) {
        saveName = "results.htm";
    } else if (curPage.equals("home")) {
        saveName = "home.htm";
    } else {
        saveName = Utils.getNameOnly(curPage);
    }
    saveName = FileUtils.addFolder(defaultSaveFolder, saveName);
    fds.setCurrentDirectory(new File(defaultSaveFolder));
    fds.setSelectedFile(new File(saveName));

    int fileGotten = fds.showDialog(this, I18n.getString("button.save"));
    if (fileGotten == JFileChooser.APPROVE_OPTION) {
        File saveFile = fds.getSelectedFile();
        setStatus(I18n.getString("button.save") + saveFile);

        // get document stream and save it
        String saveText = editorPane.getText();
        PrintWriter pw = null;
        try {
            pw = new PrintWriter(new FileWriter(saveFile));
            pw.print(saveText);
        } catch (IOException ioe) {
            logger.fatal("doSave() failed with IOException", ioe);
            showMessage(dsErrSaFi, "\n" + saveFile);
        } finally {
            IOUtils.closeQuietly(pw);
        }
    }
}

From source file:org.jax.haplotype.io.SnpStreamUtil.java

/**
 * A main for snp data conversion//  w  ww. java  2 s.  c  o m
 * @param args
 *          dont care
 * @throws IOException
 *          if we get one
 */
public static void main(String[] args) throws IOException {
    JFileChooser inputFileChooser = new JFileChooser();
    inputFileChooser.setDialogTitle("Select CSV Chromosome Input Files");
    inputFileChooser.setMultiSelectionEnabled(true);
    inputFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int userSelection = inputFileChooser.showOpenDialog(null);
    if (userSelection == JFileChooser.APPROVE_OPTION) {
        JFileChooser outputDirectoryChooser = new JFileChooser();
        outputDirectoryChooser.setDialogTitle("Select an Output Directory");
        outputDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int outputUserSelection = outputDirectoryChooser.showOpenDialog(null);

        if (outputUserSelection == JFileChooser.APPROVE_OPTION) {
            File selectedOutputDirectory = outputDirectoryChooser.getSelectedFile();
            File[] selectedInputFiles = inputFileChooser.getSelectedFiles();
            for (File selectedInputFile : selectedInputFiles) {
                writeBinaryChromosomeData(new GenotypeParser(), selectedInputFile, selectedOutputDirectory);
            }
        }
    } else {
        System.out.println("user doesn't want to open the file");
    }
}

From source file:org.jets3t.apps.cockpitlite.CockpitLite.java

/**
 * Event handler for this application, handles all menu items.
 *///from   w  w w  .j a v a  2s. c  om
public void actionPerformed(ActionEvent event) {
    if (event.getSource().equals(loginButton)) {
        new Thread() {
            @Override
            public void run() {
                listObjects();
            }
        }.start();
    }

    // Object Events
    else if ("ViewObjectProperties".equals(event.getActionCommand())) {
        listObjectProperties();
    } else if ("RefreshObjects".equals(event.getActionCommand())) {
        new Thread() {
            @Override
            public void run() {
                listObjects();
            }
        }.start();
    } else if ("TogglePublicPrivate".equals(event.getActionCommand())) {
        new Thread() {
            @Override
            public void run() {
                S3Object object = getSelectedObjects()[0];
                String aclStatus = objectTableModel.getObjectAclStatus(object);
                boolean originalAclWasPublic = ACL_PUBLIC_DESCRIPTION.equals(aclStatus);

                ToggleAclDialog dialog = new ToggleAclDialog(ownerFrame, originalAclWasPublic, null,
                        cockpitLiteProperties.getProperties());
                dialog.setVisible(true);

                // Update ACL setting.
                S3Object minimalObject = new S3Object(object.getKey());

                AccessControlList newAcl = (dialog.isPublicAclSet() ? AccessControlList.REST_CANNED_PUBLIC_READ
                        : AccessControlList.REST_CANNED_PRIVATE);

                if (newAcl != null) {
                    if (AccessControlList.REST_CANNED_PRIVATE.equals(newAcl)) {
                        minimalObject.addMetadata(Constants.REST_HEADER_PREFIX + "acl", "private");
                    } else if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(newAcl)) {
                        minimalObject.addMetadata(Constants.REST_HEADER_PREFIX + "acl", "public-read");
                    }
                }

                updateObjectsAccessControlLists(new S3Object[] { minimalObject }, newAcl);

                dialog.dispose();
            }
        }.start();
    } else if ("GeneratePublicGetURL".equals(event.getActionCommand())) {
        generatePublicGetUrl();
    } else if ("DeleteObjects".equals(event.getActionCommand())) {
        deleteSelectedObjects();
    } else if ("DownloadObjects".equals(event.getActionCommand())) {
        try {
            downloadSelectedObjects();
        } catch (Exception ex) {
            String message = "Unable to download objects from S3";
            log.error(message, ex);
            ErrorDialog.showDialog(ownerFrame, this, cockpitLiteProperties.getProperties(), message, ex);
        }
    } else if ("UploadFiles".equals(event.getActionCommand())) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setMultiSelectionEnabled(true);
        fileChooser.setDialogTitle("Choose file(s) to upload");
        fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        fileChooser.setApproveButtonText("Upload files");
        fileChooser.setCurrentDirectory(fileChoosersLastUploadDirectory);

        int returnVal = fileChooser.showOpenDialog(ownerFrame);
        if (returnVal != JFileChooser.APPROVE_OPTION) {
            return;
        }

        final File[] uploadFiles = fileChooser.getSelectedFiles();
        if (uploadFiles.length == 0) {
            return;
        }

        // Save the chosen directory location for next time.
        fileChoosersLastUploadDirectory = uploadFiles[0].getParentFile();

        new Thread() {
            @Override
            public void run() {
                prepareForFilesUpload(uploadFiles);
            }
        }.start();
    } else if (event.getSource().equals(filterObjectsCheckBox)) {
        if (filterObjectsCheckBox.isSelected()) {
            filterObjectsPanel.setVisible(true);
        } else {
            filterObjectsPanel.setVisible(false);
            filterObjectsPrefix.setText("");
        }
    }

    // Ooops...
    else {
        log.warn("Unrecognised ActionEvent command '" + event.getActionCommand() + "' in " + event);
    }
}

From source file:org.jets3t.apps.cockpitlite.CockpitLite.java

/**
 * Prepares to perform a download of objects from S3 by prompting the user for a directory
 * to store the files in, then performing the download.
 *
 * @throws IOException/*  w w  w  .ja  v  a  2  s.co m*/
 */
private void downloadSelectedObjects() throws IOException {
    // Prompt user to choose directory location for downloaded files (or cancel download altogether)
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Choose directory to save S3 files in");
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setSelectedFile(downloadDirectory);

    int returnVal = fileChooser.showDialog(ownerFrame, "Choose Directory");
    if (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }

    downloadDirectory = fileChooser.getSelectedFile();

    prepareForObjectsDownload();
}

From source file:org.kse.gui.actions.ImportCaReplyFromFileAction.java

private File chooseCaFile() {
    JFileChooser chooser = FileChooserFactory.getCaReplyFileChooser();
    chooser.setCurrentDirectory(CurrentDirectory.get());
    chooser.setDialogTitle(res.getString("ImportCaReplyFromFileAction.ImportCaReply.Title"));
    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(frame, res.getString("ImportCaReplyFromFileAction.ImportCaReply.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File openFile = chooser.getSelectedFile();
        CurrentDirectory.updateForFile(openFile);
        return openFile;
    }/* w w w  . j  a  va2 s.c  o m*/

    return null;
}

From source file:org.kse.gui.crypto.DUpgradeCryptoStrength.java

private void browsePolicyPressed() {
    JFileChooser chooser = FileChooserFactory.getZipFileChooser();

    chooser.setCurrentDirectory(CurrentDirectory.get());

    chooser.setDialogTitle(res.getString("DUpgradeCryptoStrength.Title.ChoosePolicyZip.Title"));

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this,
            res.getString("DUpgradeCryptoStrength.Title.PolicyZipChooser.button"));
    if (rtnValue == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();

        if (!chosenFile.isFile()) {
            JOptionPane.showMessageDialog(DUpgradeCryptoStrength.this,
                    res.getString("DUpgradeCryptoStrength.NotPolicyZip.message"),
                    res.getString("DUpgradeCryptoStrength.Title"), JOptionPane.WARNING_MESSAGE);
            return;
        }//from  www .ja va2 s . co  m

        processPolicyZipFile(chosenFile);
    }
}

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

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

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

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

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

    chooser.setMultiSelectionEnabled(false);

    int rtnValue = chooser.showDialog(this,
            res.getString("DImportKeyPairOpenSsl.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.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   w w w.ja va2s  .c  o 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);
    }
}