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.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * //from   w ww.j a v  a  2  s.  c  o m
 * @return TechnologyTreePanel `
 */
private TechnologyTreePanel getTechTree() {
    TechnologyTreePanel ttp = new TechnologyTreePanel(
            Constant.messages.getString("customFire.custom.tab.tech.node"));
    JFileChooser chooser = new JFileChooser(Constant.getZapHome());
    chooser.setFileFilter(new FileFilter() {
        @Override
        public boolean accept(File file) {
            if (file.isDirectory()) {
                return true;
            } else if (file.isFile() && file.getName().endsWith(".ser")) {
                return true;
            }
            return false;
        }

        @Override
        public String getDescription() {
            return Constant.messages.getString("customFire.custom.file.format.csp.ser");
        }
    });
    File file = null;
    chooser.setDialogTitle("Open Technology");
    int rc = chooser.showOpenDialog(View.getSingleton().getMainFrame());
    if (rc == JFileChooser.APPROVE_OPTION) {
        file = chooser.getSelectedFile();
        if (file == null || !file.getName().equalsIgnoreCase("Tech.ser")) {
            View.getSingleton().showWarningDialog(
                    Constant.messages.getString("customFire.custom.tech.ser.mismatch.error"));
            return ttp;
        }
        try {
            FileInputStream fis = new FileInputStream(file.getPath());
            ObjectInputStream ois = new ObjectInputStream(fis);
            ttp = (TechnologyTreePanel) ois.readObject();
            ttp.addTechTreeListener(ttp, true);
            ois.close();
            fis.close();

        } catch (IOException | ClassNotFoundException e1) {
            View.getSingleton()
                    .showWarningDialog(Constant.messages.getString("customFire.custom.ser.load.error"));
        }
    }

    techTree = ttp;

    return techTree;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * Not used as of now/*  w  w  w . j av a2s.  c  om*/
 * @return ScriptTreePanel `
 */
public ScriptTreePanel getSTree() {
    //if (sTree == null) {

    ScriptTreePanel stp = new ScriptTreePanel(Constant.messages.getString("customFire.custom.tab.script.node"));
    JFileChooser chooser = new JFileChooser(Constant.getZapHome());
    chooser.setFileFilter(new FileFilter() {
        @Override
        public boolean accept(File file) {
            if (file.isDirectory()) {
                return true;
            } else if (file.isFile() && file.getName().endsWith(".ser")) {
                return true;
            }
            return false;
        }

        @Override
        public String getDescription() {
            return Constant.messages.getString("customFire.custom.file.format.csp.ser");
        }
    });
    File file = null;
    chooser.setDialogTitle("Open Scripts settings");
    int rc = chooser.showOpenDialog(View.getSingleton().getMainFrame());
    if (rc == JFileChooser.APPROVE_OPTION) {
        file = chooser.getSelectedFile();
        if (file == null || !file.getName().equalsIgnoreCase("Scripts.ser")) {
            View.getSingleton().showWarningDialog(
                    Constant.messages.getString("customFire.custom.scripts.ser.mismatch.error"));
            return stp;
        }
        try {
            FileInputStream fis = new FileInputStream(file.getPath());
            ObjectInputStream ois = new ObjectInputStream(fis);
            stp = (ScriptTreePanel) ois.readObject();
            stp.addScriptTreeListener(stp, true);
            ois.close();
            fis.close();

        } catch (IOException | ClassNotFoundException e1) {
            View.getSingleton()
                    .showWarningDialog(Constant.messages.getString("customFire.custom.ser.load.error"));
        }
    }

    sTree = stp;
    return sTree;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 *    Gets Input Vectors tab/* ww  w. ja  va  2s .  c o m*/
 *  void `
 */
private ScannerParam getScannerParam() {

    ScannerParam sp = new ScannerParam();
    JFileChooser chooser = new JFileChooser(Constant.getZapHome());
    chooser.setFileFilter(new FileFilter() {
        @Override
        public boolean accept(File file) {
            if (file.isDirectory()) {
                return true;
            } else if (file.isFile() && file.getName().endsWith(".ser")) {
                return true;
            }
            return false;
        }

        @Override
        public String getDescription() {
            return Constant.messages.getString("customFire.custom.file.format.csp.ser");
        }
    });
    File file = null;
    chooser.setDialogTitle("Open Input Vectors");
    int rc = chooser.showOpenDialog(View.getSingleton().getMainFrame());
    if (rc == JFileChooser.APPROVE_OPTION) {
        file = chooser.getSelectedFile();
        if (file == null || !file.getName().equalsIgnoreCase("Input Vectors.ser")) {
            View.getSingleton().showWarningDialog(
                    Constant.messages.getString("customFire.custom.inputVectors.ser.mismatch.error"));
            return scannerParam;
        }
        try {
            FileInputStream fis = new FileInputStream(file.getPath());
            ObjectInputStream ois = new ObjectInputStream(fis);
            sp = (ScannerParam) ois.readObject();
            ois.close();
            fis.close();
            return sp;

        } catch (IOException | ClassNotFoundException e1) {
            View.getSingleton()
                    .showWarningDialog(Constant.messages.getString("customFire.custom.ser.load.error"));
            return scannerParam;
        }
    }

    return scannerParam;
}

From source file:osu.beatmapdownloader.JFrame.java

private void B_DirectoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_B_DirectoryActionPerformed
       JFileChooser chooser;

       chooser = new JFileChooser();
       chooser.setCurrentDirectory(new java.io.File("."));
       chooser.setDialogTitle("Open Osu! Installation Directory");
       chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
       chooser.setAcceptAllFileFilterUsed(false);
       if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
           File route = chooser.getSelectedFile();
           if (route.toString().endsWith("Songs")) {
               Directory = route.getAbsolutePath();
               T_Directory.setText(Directory);
           } else {
               if (route.isDirectory()) {
                   String[] Files = route.list();
                   boolean found = false;
                   for (String f : Files)
                       if (f.contains("Songs")) {
                           Directory = route + File.separator + f;
                           T_Directory.setText(Directory);
                           set("SongDirectory", Directory);
                           found = true;
                           break;
                       }//w  w  w .  j  a  v  a2 s . c om
                   if (found == false)
                       Alert("Incorrect Osu! Directory");
               }
           }
       }
   }

From source file:patientmanagerv1.HomeController.java

public void export() {//this is not unlike old age, and eventually death
                      //"Save As" Dialog Box:
    JFrame parentFrame = new JFrame();

    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle(
            "Save to/Save as/Save file as.../Where would you like to save this file?/ Where would you like to save this evaluation?");

    int selectedPathAndName = fileChooser.showSaveDialog(parentFrame);
    String path = "";

    if (selectedPathAndName == JFileChooser.APPROVE_OPTION) {
        File fileToSave = fileChooser.getSelectedFile();
        path = fileToSave.getAbsolutePath();

        writeEvalToDocX(true, path);/*from w ww  . ja v a  2  s.c o m*/

        //A Basic Browse Box:
        try {
            /*JFileChooser chooser = new JFileChooser();
            int value = chooser.showOpenDialog(null);
            if(value == JFileChooser.APPROVE_OPTION)
            {
                    XWPFDocument docToAppend = new XWPFDocument(new FileInputStream(chooser.getSelectedFile()));
                    XWPFWordExtractor extract = new XWPFWordExtractor(docToAppend);
                    Primary.appendText(extract.getText());
                    
            }
                    
            save();
            Primary.selectAll();
            Primary.clear();
            reinitializePrimary();*/

        } catch (Exception e) {

        }

        JOptionPane.showMessageDialog(null, "Export Successful!");
    } else {

    }
}

From source file:pcgen.gui2.dialog.ExportDialog.java

private void export(boolean pdf) {
    UIPropertyContext context = UIPropertyContext.createContext("ExportDialog");
    final JFileChooser fcExport = new JFileChooser();
    fcExport.setFileSelectionMode(JFileChooser.FILES_ONLY);
    File baseDir = null;//from  ww  w .j a va  2 s .  c o  m
    {
        String path;
        if (pdf) {
            path = context.getProperty(PDF_EXPORT_DIR_PROP);
        } else {
            path = context.getProperty(HTML_EXPORT_DIR_PROP);
        }
        if (path != null) {
            baseDir = new File(path);
        }
    }
    if (baseDir == null || !baseDir.isDirectory()) {
        baseDir = SystemUtils.getUserHome();
    }
    fcExport.setCurrentDirectory(baseDir);

    URI uri = fileList.getSelectedValue();
    String extension = ExportUtilities.getOutputExtension(uri.toString(), pdf);
    if (pdf) {
        FileFilter fileFilter = new FileNameExtensionFilter("PDF Documents (*.pdf)", "pdf");
        fcExport.addChoosableFileFilter(fileFilter);
        fcExport.setFileFilter(fileFilter);
    } else if ("htm".equalsIgnoreCase(extension) || "html".equalsIgnoreCase(extension)) {
        FileFilter fileFilter = new FileNameExtensionFilter("HTML Documents (*.htm, *.html)", "htm", "html");
        fcExport.addChoosableFileFilter(fileFilter);
        fcExport.setFileFilter(fileFilter);
    } else if ("xml".equalsIgnoreCase(extension)) {
        FileFilter fileFilter = new FileNameExtensionFilter("XML Documents (*.xml)", "xml");
        fcExport.addChoosableFileFilter(fileFilter);
        fcExport.setFileFilter(fileFilter);
    } else {
        String desc = extension + " Files (*." + extension + ")";
        fcExport.addChoosableFileFilter(new FileNameExtensionFilter(desc, extension));
    }
    String name;
    File path;
    if (!partyBox.isSelected()) {
        CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem();
        path = character.getFileRef().get();
        if (path != null) {
            path = path.getParentFile();
        } else {
            path = new File(PCGenSettings.getPcgDir());
        }
        name = character.getTabNameRef().get();
        if (StringUtils.isEmpty(name)) {
            name = character.getNameRef().get();
        }
    } else {
        path = new File(PCGenSettings.getPcgDir());
        name = "Entire Party";
    }
    if (pdf) {
        fcExport.setSelectedFile(new File(path, name + ".pdf"));
    } else {
        fcExport.setSelectedFile(new File(path, name + "." + extension));
    }
    fcExport.setDialogTitle("Export " + name);
    if (fcExport.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
        return;
    }

    final File outFile = fcExport.getSelectedFile();
    if (pdf) {
        context.setProperty(PDF_EXPORT_DIR_PROP, outFile.getParent());
    } else {
        context.setProperty(HTML_EXPORT_DIR_PROP, outFile.getParent());
    }

    if (StringUtils.isEmpty(outFile.getName())) {
        pcgenFrame.showErrorMessage("PCGen", "You must set a filename.");
        return;
    }

    if (outFile.isDirectory()) {
        pcgenFrame.showErrorMessage("PCGen", "You cannot overwrite a directory with a file.");
        return;
    }

    if (outFile.exists() && !SettingsHandler.getAlwaysOverwrite()) {
        int reallyClose = JOptionPane.showConfirmDialog(this,
                "The file " + outFile.getName() + " already exists, are you sure you want to overwrite it?",
                "Confirm overwriting " + outFile.getName(), JOptionPane.YES_NO_OPTION);

        if (reallyClose != JOptionPane.YES_OPTION) {
            return;
        }
    }
    if (pdf) {
        new PDFExporter(outFile, extension, name).execute();
    } else {
        if (!printToFile(outFile)) {
            String message = "The character export failed. Please see the log for details.";
            pcgenFrame.showErrorMessage(Constants.APPLICATION_NAME, message);
            return;
        }
        maybeOpenFile(outFile);
        Globals.executePostExportCommandStandard(outFile.getAbsolutePath());
    }
}

From source file:pcgen.gui2.facade.SpellSupportFacadeImpl.java

@Override
public void exportSpells() {
    final String template = PCGenSettings.getInstance().getProperty(PCGenSettings.SELECTED_SPELL_SHEET_PATH);
    if (StringUtils.isEmpty(template)) {
        delegate.showErrorMessage(Constants.APPLICATION_NAME, LanguageBundle.getString("in_spellNoSheet")); //$NON-NLS-1$
        return;//w  ww.j  a  va2  s.com
    }
    String ext = template.substring(template.lastIndexOf('.'));

    // Get the name of the file to output to.
    JFileChooser fcExport = new JFileChooser();
    fcExport.setCurrentDirectory(new File(PCGenSettings.getPcgDir()));
    fcExport.setDialogTitle(
            LanguageBundle.getString("InfoSpells.export.spells.for") + charDisplay.getDisplayName()); //$NON-NLS-1$

    if (fcExport.showSaveDialog(null) != JFileChooser.APPROVE_OPTION) {
        return;
    }
    final String aFileName = fcExport.getSelectedFile().getAbsolutePath();
    if (aFileName.length() < 1) {
        delegate.showErrorMessage(Constants.APPLICATION_NAME,
                LanguageBundle.getString("InfoSpells.must.set.filename")); //$NON-NLS-1$ 
        return;
    }

    try {
        final File outFile = new File(aFileName);

        if (outFile.isDirectory()) {
            delegate.showErrorMessage(Constants.APPLICATION_NAME,
                    LanguageBundle.getString("InfoSpells.can.not.overwrite.directory")); //$NON-NLS-1$ 
            return;
        }

        if (outFile.exists()) {
            int reallyClose = JOptionPane.showConfirmDialog(null,
                    LanguageBundle.getFormattedString("InfoSpells.confirm.overwrite", outFile.getName()), //$NON-NLS-1$
                    LanguageBundle.getFormattedString("InfoSpells.overwriting", //$NON-NLS-1$
                            outFile.getName()),
                    JOptionPane.YES_NO_OPTION);

            if (reallyClose != JOptionPane.YES_OPTION) {
                return;
            }
        }

        // Output the file
        File templateFile = new File(template);
        boolean success;
        if (ExportUtilities.isPdfTemplate(templateFile)) {
            success = BatchExporter.exportCharacterToPDF(pcFacade, outFile, templateFile);
        } else {
            success = BatchExporter.exportCharacterToNonPDF(pcFacade, outFile, templateFile);
        }

        if (!success) {
            delegate.showErrorMessage(Constants.APPLICATION_NAME, LanguageBundle
                    .getFormattedString("InfoSpells.export.failed", charDisplay.getDisplayName())); //$NON-NLS-1$ 
        }
    } catch (Exception ex) {
        Logging.errorPrint(
                LanguageBundle.getFormattedString("InfoSpells.export.failed", charDisplay.getDisplayName()), //$NON-NLS-1$
                ex);
        delegate.showErrorMessage(Constants.APPLICATION_NAME, LanguageBundle
                .getFormattedString("InfoSpells.export.failed.retry", charDisplay.getDisplayName())); //$NON-NLS-1$ 
    }
}

From source file:pcgen.gui2.prefs.LookAndFeelPanel.java

private void selectThemePack() {
    JFileChooser fc = new JFileChooser(ConfigurationSettings.getThemePackDir());
    fc.setDialogTitle(LanguageBundle.getString("in_Prefs_chooseSkinDialogTitle"));

    String theme = LookAndFeelManager.getCurrentThemePack();

    if (StringUtils.isNotEmpty(theme)) {
        fc.setCurrentDirectory(new File(LookAndFeelManager.getCurrentThemePack()));
        fc.setSelectedFile(new File(LookAndFeelManager.getCurrentThemePack()));
    }/*from   w w w .ja v a 2 s  . c  o m*/

    fc.addChoosableFileFilter(new ThemePackFilter());

    if (fc.showOpenDialog(getParent().getParent()) == JFileChooser.APPROVE_OPTION) //ugly, but it works
    {
        File newTheme = fc.getSelectedFile();

        if (newTheme.isDirectory() || (!newTheme.getName().endsWith("themepack.zip"))) {
            ShowMessageDelegate.showMessageDialog(LanguageBundle.getString("in_Prefs_notAThemeErrorItem"),
                    Constants.APPLICATION_NAME, MessageType.ERROR);
        } else {
            LookAndFeelManager.setSelectedThemePack(newTheme.getAbsolutePath());
        }
    }
}

From source file:pcgen.gui2.tools.DesktopBrowserLauncher.java

/**
 * Sets the default browser./* w  w w.j a v a2  s.  co m*/
 */
public static void selectDefaultBrowser() {
    final JFileChooser fc = new JFileChooser();
    fc.setDialogTitle("Find and select your preferred html browser.");

    if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        fc.putClientProperty("JFileChooser.appBundleIsTraversable", "never");
    }

    if (PCGenSettings.getBrowserPath() != null) {
        fc.setCurrentDirectory(new File(PCGenSettings.getBrowserPath()));
    }

    final int returnVal = fc.showOpenDialog(null);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        final File file = fc.getSelectedFile();
        PCGenSettings.OPTIONS_CONTEXT.setProperty(PCGenSettings.BROWSER_PATH, file.getAbsolutePath());
    }
}

From source file:pcgen.gui2.tools.Utility.java

/**
 * Sets the default browser.//from w w w  . ja  va2 s . c o m
 *
 * @param parent The component to show the dialog over.
 */
public static void selectDefaultBrowser(Component parent) {
    final JFileChooser fc = new JFileChooser();
    fc.setDialogTitle("Find and select your preferred html browser.");

    if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
        // On MacOS X, do not traverse file bundles
        fc.putClientProperty("JFileChooser.appBundleIsTraversable", "never");
    }

    if (PCGenSettings.getBrowserPath() == null) {
        //No action, as we have no idea what a good default would be...
    } else {
        fc.setCurrentDirectory(new File(PCGenSettings.getBrowserPath()));
    }

    final int returnVal = fc.showOpenDialog(parent);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        final File file = fc.getSelectedFile();
        PCGenSettings.OPTIONS_CONTEXT.setProperty(PCGenSettings.BROWSER_PATH, file.getAbsolutePath());
    }
}