• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFileChooser

 
tormod eriksen
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
tormod eriksen
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic