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 .

Recommended Answers

All 3 Replies

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

Thanks Richard ! you added some content to my mind dictionary.

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.