Wait a minute... you mentioned the way MS Word works, in other words you want to save the data in the same file it was loaded from?
If that's the question, then sure. When you load the data from a file, save the file's path in a variable somewhere. Then use that variable as the name of the file when you go to save the data.
Joined: Jun 15, 2012
Thanks very much for responding... Sorry the request is a bit crytic... I want the application to work like word.. So a user can open a file edit it and save it..
Or they can create a new file from scratch... If they edit an existing file i want them to be able to just hit save and I can do like you said to save the file name etc..
However, how do I prevent the dialog box from popping up? Like in for eg word you can just hit the save icon etc and nothing pops up...
This is my code, quite basic!!!
You just remove that code. Remember, a JFileChooser is just what its name says, a thing for choosing a file. You already have the name of the file you want to save to, so you can skip the step which displays the JFileChooser and go directly to the code which saves the data in the file with that name.
Yes. You can read about file choosers here, but if you already have the file's details you don't need a chooser. I recommend you learn the newer ways to handle files, which you can read about under file I/O (NIO2).