0

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..??

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jogendar
0

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

0

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...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.