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
setSelectedFile doesn't work with directories as mentioned above, a solution is
try {
FileChooserUI fcUi = fileChooser.getUI();
fcUi.setSelectedFile(defaultDir);
Class extends FileChooserUI> fcClass = fcUi.getClass();
Method setFileName = fcClass.getMethod("setFileName", String.class);
setFileName.invoke(fcUi, defaultDir.getName());
} catch (Exception e) {
e.printStackTrace();
}
Unfortunately the setFileName is not included in the UI interface, thus the need to call it dynamically. Only tested on mac.