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:phex.gui.common.FileDialogHandler.java

private static JFileChooser initDefaultChooser(String title, String approveBtnText, char approveBtnMnemonic,
        FileFilter filter, int mode, File currentDirectory, String notifyPopupTitle,
        String notifyPopupShortMessage) {
    JFileChooser chooser = new JFileChooser();

    if (notifyPopupTitle != null || notifyPopupShortMessage != null) {
        displayNotificationPopup(chooser, notifyPopupTitle, notifyPopupShortMessage);
    }//from   w w  w . j a  va 2s  . co  m

    if (currentDirectory != null) {
        chooser.setCurrentDirectory(currentDirectory);
    }
    if (filter != null) {
        chooser.setFileFilter(filter);
    }
    chooser.setFileSelectionMode(mode);
    chooser.setDialogTitle(title);
    chooser.setApproveButtonText(approveBtnText);
    chooser.setApproveButtonMnemonic(approveBtnMnemonic);
    return chooser;
}

From source file:pl.edu.pw.appt.GUI.java

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Zapisz plik jako...");

    FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("Pliki UMLDump (*.umldump)", "umldump");
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setFileFilter(xmlfilter);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss");
    fileChooser.setSelectedFile(new File(df.format(new Date())));

    int userSelection = fileChooser.showSaveDialog(this);
    if (userSelection == JFileChooser.APPROVE_OPTION) {
        File fileToSave = fileChooser.getSelectedFile();
        if (!FilenameUtils.getExtension(fileToSave.getName()).equalsIgnoreCase("umldump")) {
            fileToSave = new File(fileToSave.getParentFile(),
                    FilenameUtils.getBaseName(fileToSave.getName()) + ".umldump");
        }/*from   w  w  w.ja  va 2 s .  c  om*/
        try {
            FileHandler.saveFile(Paths.get(fileToSave.getAbsolutePath()),
                    server.messages.toString(selectSystem.getSelectedItem().toString()));
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Nie udao si zapisa pliku.", "Wystpi bd",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:pl.edu.pw.appt.GUI.java

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Zapisz obraz jako...");

    FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("Pliki BMP (*.bmp)", "bmp");
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setFileFilter(xmlfilter);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss");
    fileChooser.setSelectedFile(new File(df.format(new Date())));

    int userSelection = fileChooser.showSaveDialog(this);
    if (userSelection == JFileChooser.APPROVE_OPTION) {
        File fileToSave = fileChooser.getSelectedFile();
        if (!FilenameUtils.getExtension(fileToSave.getName()).equalsIgnoreCase("bmp")) {
            fileToSave = new File(fileToSave.getParentFile(),
                    FilenameUtils.getBaseName(fileToSave.getName()) + ".bmp");
        }//from  www .j a va  2 s .c  om
        try {
            ImageIO.write((RenderedImage) image, "bmp", fileToSave);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Nie udao si zapisa obrazu.", "Wystpi bd",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:plugin.notes.gui.NotesView.java

/**
 *  obtains an Image for input using a custom JFileChooser dialog
 *
 *@param  startDir  Directory to open JFielChooser to
 *@param  exts      Extensions to search for
 *@param  desc      Description for files
 *@return           File pointing to the selected image
 *//*from w  ww . ja v a2 s  .  c om*/
private File getImageFromChooser(String startDir, String[] exts, String desc) {
    JFileChooser jImageDialog = new JFileChooser();
    jImageDialog.setCurrentDirectory(new File(startDir));
    jImageDialog.setAccessory(new ImageFileChooserPreview(jImageDialog));
    jImageDialog.setDialogType(JFileChooser.CUSTOM_DIALOG);
    jImageDialog.setFileFilter(new FileNameExtensionFilter(desc, exts));
    jImageDialog.setDialogTitle("Select an Image to Insert");

    int optionSelected = jImageDialog.showDialog(this, "Insert");

    if (optionSelected == JFileChooser.APPROVE_OPTION) {
        return jImageDialog.getSelectedFile();
    }

    return null;
}

From source file:PolyGlot.IOHandler.java

/**
 * Queries user for image file, and returns it
 * @param parent the parent window from which this is called
 * @return the image chosen by the user, null if canceled
 * @throws IOException If the image cannot be opened for some reason
 *//*  w ww .j ava 2 s .c  om*/
public static BufferedImage openImageFile(Component parent) throws IOException {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Open Images");
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "gif", "jpg", "jpeg", "bmp",
            "png", "wbmp");
    chooser.setFileFilter(filter);
    String fileName;
    chooser.setCurrentDirectory(new File("."));

    if (chooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
        fileName = chooser.getSelectedFile().getAbsolutePath();
    } else {
        return null;
    }

    return getImage(fileName);
}

From source file:processing.app.Base.java

static public File selectFolder(String prompt, File folder, Component parent) {
    JFileChooser fc = new JFileChooser();
    fc.setDialogTitle(prompt);
    if (folder != null) {
        fc.setSelectedFile(folder);/*from   w  w w  .  j a  va2s. c  o m*/
    }
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    int returned = fc.showOpenDialog(parent);
    if (returned == JFileChooser.APPROVE_OPTION) {
        return fc.getSelectedFile();
    }
    return null;
}

From source file:processing.app.Base.java

public void handleAddLibrary() {
    JFileChooser fileChooser = new JFileChooser(System.getProperty("user.home"));
    fileChooser.setDialogTitle(tr("Select a zip file or a folder containing the library you'd like to add"));
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setFileFilter(new FileNameExtensionFilter(tr("ZIP files or folders"), "zip"));

    Dimension preferredSize = fileChooser.getPreferredSize();
    fileChooser.setPreferredSize(new Dimension(preferredSize.width + 200, preferredSize.height + 200));

    int returnVal = fileChooser.showOpenDialog(activeEditor);

    if (returnVal != JFileChooser.APPROVE_OPTION) {
        return;/* w w w.ja v a  2  s  .c o m*/
    }

    File sourceFile = fileChooser.getSelectedFile();
    File tmpFolder = null;

    try {
        // unpack ZIP
        if (!sourceFile.isDirectory()) {
            try {
                tmpFolder = FileUtils.createTempFolder();
                ZipDeflater zipDeflater = new ZipDeflater(sourceFile, tmpFolder);
                zipDeflater.deflate();
                File[] foldersInTmpFolder = tmpFolder.listFiles(new OnlyDirs());
                if (foldersInTmpFolder.length != 1) {
                    throw new IOException(tr("Zip doesn't contain a library"));
                }
                sourceFile = foldersInTmpFolder[0];
            } catch (IOException e) {
                activeEditor.statusError(e);
                return;
            }
        }

        File libFolder = sourceFile;
        if (FileUtils.isSubDirectory(new File(PreferencesData.get("sketchbook.path")), libFolder)) {
            activeEditor.statusError(tr("A subfolder of your sketchbook is not a valid library"));
            return;
        }

        if (FileUtils.isSubDirectory(libFolder, new File(PreferencesData.get("sketchbook.path")))) {
            activeEditor.statusError(tr("You can't import a folder that contains your sketchbook"));
            return;
        }

        String libName = libFolder.getName();
        if (!BaseNoGui.isSanitaryName(libName)) {
            String mess = I18n.format(tr("The library \"{0}\" cannot be used.\n"
                    + "Library names must contain only basic letters and numbers.\n"
                    + "(ASCII only and no spaces, and it cannot start with a number)"), libName);
            activeEditor.statusError(mess);
            return;
        }

        String[] headers;
        File libProp = new File(libFolder, "library.properties");
        File srcFolder = new File(libFolder, "src");
        if (libProp.exists() && srcFolder.isDirectory()) {
            headers = BaseNoGui.headerListFromIncludePath(srcFolder);
        } else {
            headers = BaseNoGui.headerListFromIncludePath(libFolder);
        }
        if (headers.length == 0) {
            activeEditor.statusError(tr("Specified folder/zip file does not contain a valid library"));
            return;
        }

        // copy folder
        File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder().folder,
                sourceFile.getName());
        if (!destinationFolder.mkdir()) {
            activeEditor
                    .statusError(I18n.format(tr("A library named {0} already exists"), sourceFile.getName()));
            return;
        }
        try {
            FileUtils.copy(sourceFile, destinationFolder);
        } catch (IOException e) {
            activeEditor.statusError(e);
            return;
        }
        activeEditor.statusNotice(tr("Library added to your libraries. Check \"Include library\" menu"));
    } catch (IOException e) {
        // FIXME error when importing. ignoring :(
    } finally {
        // delete zip created temp folder, if exists
        newLibraryImported = true;
        FileUtils.recursiveDelete(tmpFolder);
    }
}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

private void dcm2JPEG(int thumbnailSize) {

    /**/*from w ww  .  j ava2  s  .co  m*/
     * Why couldn't? It works!
            
    if (System.getProperty("os.name").toUpperCase().indexOf("MAC OS") != -1) {
    JOptionPane.showMessageDialog(this, "Operation Not Available to MAC OS.", "Missing JAI Tool", JOptionPane.WARNING_MESSAGE);
    return;
    }
     */
    String pathDir = ".";

    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new java.io.File(pathDir));
    chooser.setDialogTitle("Dicoogle Dcm2JPG - Select DICOM File");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    //chooser.setFileFilter(arg0)
    chooser.setAcceptAllFileFilterUsed(false);

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        File filePath = new File(chooser.getSelectedFile().toString());
        if (filePath.exists() && filePath.isFile() && filePath.canRead()) {
            File jpgFile = new File(filePath.getAbsolutePath() + ".jpg");
            Dicom2JPEG.convertDicom2Jpeg(filePath, jpgFile, thumbnailSize);
        }
    }
}

From source file:quake3mapfixer.Pk3Fixer.java

private void fileChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileChooserActionPerformed
    Boolean old = UIManager.getBoolean("FileChooser.readOnly");
    UIManager.put("FileChooser.readOnly", Boolean.TRUE);
    JFileChooser chooser = new JFileChooser();
    UIManager.put("FileChooser.readOnly", old);
    FileNameExtensionFilter pk3filter = new FileNameExtensionFilter("pk3 files (*.pk3)", "pk3");
    chooser.setFileFilter(pk3filter);//from   w ww.j ava 2  s .co m
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setDialogTitle("Open pk3 file");
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        currentDirectory = chooser.getCurrentDirectory().toString();
        selectedFile = chooser.getSelectedFile().toString();
        absolutePath = chooser.getSelectedFile().getName();
        areaFileName.setText(selectedFile);
        fileFixer.setEnabled(true);
    }

}

From source file:rmeteorj.GUI.GUI.java

/**
 * Open file for detection or analysis/*www .j a v  a  2s .  c  o  m*/
 */
public static void openFile() {
    JFileChooser fc = new JFileChooser();
    fc.setDialogTitle("Open file");
    fc.setMultiSelectionEnabled(true);

    int response = fc.showOpenDialog(MainWindow.getInstance());

    if (response == JFileChooser.APPROVE_OPTION) {
        String[] options = ArrayUtils.addAll(ModuleManager.getManager().getEnabledDetectModulesNames(),
                ModuleManager.getManager().getEnabledAnalyzeModulesNames());
        if (options.length == 0) {
            JOptionPane.showMessageDialog(MainWindow.getInstance(), "Enable detect or analyze module first.");
            return;
        }
        options[options.length] = "Cancel";

        String moduleName = (String) JOptionPane.showInputDialog(MainWindow.getInstance(),
                "Send opened files to: ", "Open file", JOptionPane.QUESTION_MESSAGE, null, options, options[0]);

        if (!moduleName.equals("Cancel")) {
            ModuleManager.getManager().openFilesAnalyzeOrDetect(fc.getSelectedFiles(), moduleName);
        }
    }
}