JFileChooser.showSaveDialog(…) - how to set suggested file name

前端 未结 3 1129
后悔当初
后悔当初 2020-11-30 04:43

The JFileChooser seems to be missing afeature: a way to suggest the file name when saving a file (the thing that usually gets selected so that it would get repl

3条回答
  •  盖世英雄少女心
    2020-11-30 04:54

    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.

提交回复
热议问题