Java JFileChooser getFileFromChooserSave()

Here you can find the source of getFileFromChooserSave()

Description

get File From Chooser Save

License

Open Source License

Declaration

public static File getFileFromChooserSave() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import javax.swing.JFileChooser;

public class Main {
    public static File getFileFromChooserSave() {
        JFileChooser chooser = new JFileChooser();
        chooser.setDialogTitle("save as file");
        chooser.setSize(new java.awt.Dimension(45, 37)); // Generated
        //        chooser.setFileFilter(new FileNameExtensionFilter("png", "png"));
        File file = null;/*from  www. j a v a2 s . c om*/
        if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            file = chooser.getSelectedFile();
            return file;
        }
        return file;
    }

    public static File getFileFromChooserSave(String folderPath) {
        JFileChooser chooser = new JFileChooser(folderPath);
        chooser.setDialogTitle("save as file");
        chooser.setSize(new java.awt.Dimension(45, 37)); // Generated
        //        chooser.setFileFilter(new FileNameExtensionFilter("png", "png"));
        File file = null;
        if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
            file = chooser.getSelectedFile();
            return file;
        }
        return file;
    }
}

Related

  1. getFileChooser()
  2. getFileChooser()
  3. getFileChooser(Component parent, JFileChooser fileChooser, JComponent accessory)
  4. getFileChooserSelectedFile(JFileChooser fchooser, boolean directoryOnly, String fileName)
  5. getFileFromChooserForPNG()
  6. getFileName(Component parent)
  7. getFileOrDir(String startName, boolean fileSelect)
  8. getFilePath()
  9. getFilePath(Component parent, JFileChooser fileChooser, String title, FileFilter filter)