FileDialog Creation

Can somebody pls show mi how to create the FileDialog for saving a file ? i have alrady create the Dialog alrady......it juz that it couldn't save the file that i want.....I am new to Java Programming... so hope that i can ask for your help... Thanks
[293 byte] By [evanchoy] at [2007-9-26 2:35:52]
# 1

just the basics

<code>

JFileChooser saver = new JFileChooser();

int val = saver.showSaveDialog(this);

if (val == JFileChooser.APPROVE_OPTION)

//assume an already created File variable file

file = saver.getSelectedFile();

else

return;

// save the file to hard drive

try {//assume you have some text area named editor

editor.write( new BufferedWriter( new FileWriter(file) ) );

}

catch (IOException ioe) {

ioe.printStackTrace();

}

</code>

That should get you started anyway

garyjones32 at 2007-6-29 10:02:51 > top of Java-index,Archived Forums,Java Programming...
# 2

Here's a simple example of using FileDialog instead of JFileChooser//parentFrame is the GUI Frame

FileDialog fileDialog = new FileDialog(parentFrame,"Title");

fileDialog.setMode(FileDialog.SAVE);

fileDialog.show();

String yourNewFileName = fileDialog.getFile();

File saveFile = new File(yourNewFileName);

saveFile.createNewFile();

//

//now copy your data to the file...

//

artntek at 2007-6-29 10:02:51 > top of Java-index,Archived Forums,Java Programming...
# 3
Thanks for your help .....
evanchoy at 2007-6-29 10:02:52 > top of Java-index,Archived Forums,Java Programming...