• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JFileChooser

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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(?)
 
reply
    Bookmark Topic Watch Topic
  • New Topic