The red box is showing the issue where the full file path appears when the user double clicks on a folder directory.
There are times when the text field contains full file path that is too long (as in, the folder opened is nested deeply among folders), thus blocking out the file name. Other times, when the user is saving a file, it is possible to save a file with the file name as long as what is in the text field, in this case the file path as the file name.
How to get rid of this behavior?
Here's how to change the behavior:
First, you need this method to scour all Components in JFileChooser:
Next, we need to find all MouseListeners available from the JList of all components, and remove all of them. It is possible that some MouseListeners may register double clicks and will affect how the text field displays its text. This will help to remove all of those affecting MouseListeners.
But removing MouseListeners will also affect how the JFileChooser is to handle opening files. We need to handle this action ourselves. Here's a simple way to do this.
Now, whenever the user double clicks on a folder/directory, JFileChooser will no longer display long file paths in the text field. And it now looks better. You may have to handle opening files after double clicking on your own.
Hope you find this somewhat helpful!