I'm having the following problem with a JFileChooser: I create a save dialog and then when I'm trying to save a file, I'm entering a file name into the field and click "Save". Suppose that the directory, which I try to save my file to, contains a subdirectory, which is named exactly like the entered name. In this case JFileChooser opens it instead of saving my file, and I don't know how to make it save a file instead of opening the directory with the same name.
I tried to do something with the file filters, with approveSelection()
and changed UI from Windows to default - nothing helps. How to make JFileChooser stop opening a folder and save the file? Is there some way to modify the behavior of the button or am I just doing something wrong?
Update: To be clear: I'm not trying to save a file with the same name, I'm just trying to make JFileChooser get the path so I could append an extension to it. However, I checked Word and Photoshop, neither of them is able to do what I request, so I guess I wish to make everything too perfect. But if there's a way to do what I want, I'll still be glad to hear the solution.