What I want to do is have a JFileChooser Save Dialog box to select the destination and file name of the file I will save. I have never worked with these before, but I am trying to figure them out.
Right now, I have it so I can open up the dialog box and choose where I want to save it and what to call it, this works fine, but what I want to do is have it so that the existing file name and directory and file name (the one I want to have set by default) is where the dialog box opens up to. for example: if the file name is bob.txt in the C:\ directory, wheN I push the button to open the dialog box, the box pops up and is in the C:\ directory, it has "bob" in the file name box, and has the ".txt" selected in the file type combo box. how would I do this?
I know this may seem rather simple for some of you, but I dont know of any resources to help me figure this out (I dont have a Java book that covers this, and java.sun.com explanations only leave me confused. if you could help me, or better yet give a link to a good tutorial (not java.sun.com) so that I could solve my own problems in the future, that would be great, thanks.
OK that works, I was sure exactly what the file in parenthsis was supose to be, but I figured it out.
New Question: after the user selectes the file name they want and file type (.txt for example), and click on the save button, how can I get the extention that they selected from the file type combo box, right now when I go and get the file name and directory, I dont have the extention .txt in it unless the user included it there themsleves.
and also, if the filename already has a txt extention on it, how can I make the txt extention file type select itself from the file type list, and not go by default to the top one on the list.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop