• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser question

 
Banana Tower
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Brian Martin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How's this?

brian
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Much better. Thank you.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, much better!

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!