It works fine, but the problem is that user must enter a filename for it to work, and I don't care about a filename. In my program, saved filename are hardcoded and always have the same name so I only care about the path.
Is there a way to open a JFileChooser but without a filename field, but where user can browse to the desired directory and hit save?
You get a File object back from getSelectedFile(), which represents a directory in this case. You should then use the File constructor that takes a parent File.