I wanna ask .... if I want to save the content of JEditorPane or JTextPane in a file without losing the formatting ... how should I do it ....
If I save it to a string ... all the formatting is lost .

14 Years
Discussion Span
Last Post by nanosani

No one did solve my problem ... I solved it myself LOL.

I created another file named "filename.for" and saved the font, background, foreground and font size info in it ... and when opening a file looking for that filename.for ... if found ... apply everything likewise ... if the file is not found ... simply write the contents of the file as is.


Hi everyone,
I know you asked this question some time ago but i now know how to do this. First get the document of the jtextpane and then save it as an object for a saving function and load it as a object and then referencing it as a document
textpane.setDocument(your saved document)

When you do this you only save one file and not two files like you described above

Well better late than never.

Yours Sincerely

Richard West

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.