Reputation: 2409
I'm developing an application in which I want to create an 'MS-EXCEL' file and for that I want the name for the file to be given by user and later on I want to provide an option to the user to save at the path where it wants. I know about JFileChooser but it only allows to select a file from the existing files whereas I want to save. What can be the way? Please give me some brief description.
Upvotes: 1
Views: 10956
Reputation: 44063
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int option = chooser.showSaveDialog(null);
if (option == JFileChooser.APPROVE_OPTION)
{
// do soemthing
}
Upvotes: 2
Reputation: 9426
You can use JFileChooser.setFileSelectionMode
to allow selection of either files, directories, or both files and directories.
You can also type in the name of a file that doesn't already exist.
Upvotes: 2