How can i make JFileChooser only display name of selected/chosen files, not selected/chosen directories in the TextField to the right of the File name: label? I thought maybe setFileSelectionMode(JFileChooser.FILES_ONLY) would be a solution, but still I can see directories, and their name is also displayed in the TextField if I select them.
I don't believe that you can. Not with any simple method call that is. There is a default action when you click on the JTextArea that sends that text down to the JTextField of the JFileChooser. You would have to dig pretty deep to find that action and disable it. Out of curiosity, why is this a problem?
It's not a huge problem, but I think it's a little inconvenient sometimes. Let's say one writes a filename, then wants to save it in another directory, then one has to either select the text, then copy it or write the name again. Also if one wants a similar or identical filename to a file in another directory, then one can select that, go to the correct directory and save. I'm also used to this behaviour from other applications I use (not show directorynames). And do you know of times when you want to display the name of a directory there. That's more seldom I would guess(?)