I'm creating a basic Swing applcation. I have jTextPane and a button. If the user selects text in the jTextPane and presses the button, it bolds the selected text. This is done by modifying the StyleDocument.
I want to be able to save the styled text temporarily, close the previous jTextPane, open up a new jTextPane, and populate it based off the previous saved styled text. jTextPane takes a StyleDocument in the constructor, but when I try to construct a new jTextPane with the old StyleDocument, it doesn't appear to be working. I figure it's because I'm just passing in the reference from the previous jTextPane StyleDocument which is eventually removed.
Is there any way to copy or clone a StyleDocument? I understand it's an interface, but is it using a DefaultStyledDocument? Is there a better way of doing this?