• 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 question

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I have a quick little question about this class.
For the most part the docs are straightforward but I am having one small problem created a SAVE File dialog. I have a situation where the name of the file is pre-populated in the file name text field when the save dialog pops up. So basically I need the user to choose a location rather than a name. This works fine but as the user navigates around the directories , the file name in the text field changes depending on these files. Is there a way I can prevent this name from changing?
thanks,

brian
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Banana,
Since you are actually looking for directories why not use the JFileChooser to do only that. Look at
setFileSelectionMode
and the field
DIRECTORIES_ONLY
Regards,
Manfred.
 
Banana Tower
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Manfred!
but my problem still exists. Setting the fileSelectMode gets me to the point of choosing directories but I still get the problem of having to re-type the name of the file chosen to be saved.
I think I'll have to hack something in that keeps the name the same whenever I click on other directories in the JFileBrowse GUI.
I have noticed this effect even with Linux/Unix apps where you are given a dialog to save a file off a webpage or whereever. You right click to save the file, the save dialog appears with the right name of that file in the filename field. But as soon as you change directories, that name is changed based on what file or directory you clicked on. grrrr. Maybe I am just missing something here.....

thanks anyways,
brian
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Banana Tower,

Please re-register with a user-name that conforms to the JavaRanch Username Conventions... Usernames are required to be in the format "First Name" + space + "Last Name" and to not be obviously fake.

Thanks,
-Nate
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How's this?

brian
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Much better. Thank you.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, much better!

-Nate
 
Just the other day, I was thinking ... about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic