wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JFileChooser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser" Watch "JFileChooser" New topic
Author

JFileChooser

tormod eriksen
Ranch Hand

Joined: Jan 23, 2002
Posts: 52
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.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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?


GenRocket - Experts at Building Test Data
tormod eriksen
Ranch Hand

Joined: Jan 23, 2002
Posts: 52
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(?)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFileChooser