File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Putting a Default Name to file Using JFileChooser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Putting a Default Name to file Using JFileChooser" Watch "Putting a Default Name to file Using JFileChooser" New topic
Author

Putting a Default Name to file Using JFileChooser

Mohammed Ajmal
Greenhorn

Joined: Sep 20, 2004
Posts: 29
Hi,

I am using JFileChooser for saving the contents to a file. Here my problem is to give some name by default to a file. So the user need not give any problem. He has to just click save. The file name is combination of some id date and time.

Can somebody guide me in proceeding for the same if it is possible.

Thanks,
Ajmal
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
Why use the JFileChooser ? If you don't want the user to control the naming and placement of stored files, just provide the user with a save button and write the file to disk using your criteria.
Mohammed Ajmal
Greenhorn

Joined: Sep 20, 2004
Posts: 29
Hi,

We can set the default filename for JFileChooser save dialog using the property called setSelectedFile(filename),and it is displayed under filename text box.

Thanks,
Ajmal
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Putting a Default Name to file Using JFileChooser
 
Similar Threads
saving a text file using JFileChooser
JFileChooser:file name field becomes blank
Network file in JFiLechooser
Jfilechooser problem
problem in creating directory using JFileChooser(code included)