Here you can find the source of selectSaveFile(JMenuBar menuBar)
public static String selectSaveFile(JMenuBar menuBar)
//package com.java2s; //License from project: Open Source License import java.io.File; import javax.swing.JFileChooser; import javax.swing.JMenuBar; public class Main { public static String selectSaveFile(JMenuBar menuBar) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Specify a file to save"); int userSelection = fileChooser.showSaveDialog(menuBar); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = fileChooser.getSelectedFile(); System.out.println("Save as file: " + fileToSave.getAbsolutePath()); return fileToSave.getAbsolutePath(); }/*from w w w . j a v a2 s . c o m*/ return ""; } }