Alex Rivera | Logout

How do I set a suggested file name using JFileChooser.showSaveDialog(...)?

Asked 2008-12-10T16:30:47.160
68

The JFileChooser seems to be missing a feature: a way to suggest the file name when saving a file (the thing that usually gets selected so that it would get replaced when the user starts typing).

Is there a way around this?

Edit
Report

1 Answer

1

If that doesn't work, here is a workaround:

dialog.getUI().setFileName( name )

But you should check whether the selection mode is FILES_ONLY or FILES_AND_DIRECTORIES. If it's DIRECTORIES_ONLY, then setSelectedFile() will strip the file name.

answered 2011-07-11T15:18:24.593

Your Answer