i have used the following code to save the text in a textpane into a file

final RTFEditorKit kit = new RTFEditorKit();
jta.setEditorKit(kit);
jfr.setTitle(fname.getName());
OutputStream out = new FileOutputStream(fname);
kit.write(out,doc,0,doc.getLength());
out.close();

where jfr is the main frame,jta is the textpane,fname is the filename given by the user,doc is the styled document of the text pane...

my problem is that when i give the filename and click save button the text is stored in the file but the textpane is made empty..why is that happening..??

i think you gave fanme=file.txt..

or user may type it...

you should try fname="c://user//deskto//file.txt" or location that you wish

no yar i tried it but doesnt worked,another problem is that it is working fine if the code

final RTFEditorKit kit = new RTFEditorKit();
jta.setEditorKit(kit);

is placed at the declaration of textpane,but when i keep there undo for this pane is not working,so i kept in the save function,if i do so the above mentioned error is coming...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.