I am writing a very simple text editor and have gone into a small problem.
When saving a file, the user will not be prompted to overwrite, cancel, or overwrite the file while saving the file (option to try again).
A Jeffery Chase that will prompt the user to overwrite: Yes, No, Canceled
In case of any selection, he should go back to the JephilClos dialog, but only me It does not know how can someone help me on this? Cancellation and Yes options are not any problems (as far as I know, have not tested in depth)
string content = textaria.gate text (); If (Openpath! = Null) {savePath = openPath; } And if (saveAsPath! = Null) {savePath = saveAsPath; } And if (savePath! = Null) {savePath = savePath; } And if (Openpath == empty) {JFileChooser saveFile = New JFileChooser (); Int returnVal = saveFile.showOpenDialog (empty); If (returnVal == saveFile.APPROVE_OPTION) {savePath = saveFile.getSelectedFile (); If (SavePath.exists ()) {FileWriter fstream = New FileWriter (savePath); BufferedWriter saveVrite = new buffed water (fstream); SaveWrite.write (content); SaveWrite.close (); } And if (savepat.exists ()) {JOptionPane overwritePrompt = newZopePane (); Object [] option = {"yes", "no", "cancel"}; Int n = JOptionPane.showOptionDialog (overwrite published, "already exists, overwrite?", "Overwrite file?", Joppanpan. YES_NO_CANCEL_OPTION, JOHNptionPan. WARNING_MESSAGE, NULL, OPTION, OPTION [2]); If (n == 0) {FileWriter fstream = new FileWriter (saveAsPath); Outside buffer = new buffed waist (fstream); Out.write (content); Out.close (); } And if (n == 1) {savePath = null; Openpath = null; SaveAsPath = null; Return; // JFileChooser} {savePath = null; Openpath = null; SaveAsPath = null; Return; }}} {Return; }
About launching on this line:
complete return Val = saveFile.showOpenDialog (faucet);
Again, when should you go back to Jeffileclosures? Do I think the same file selector will again show off their open dialogue?
Comments
Post a Comment