I am making a text editor roughly like a microsoft word and I am using a textpane with HTML. After doing some research I found a way to apply html to a highlighted section on using StyleConstants and then a method that goes JTextPane.getStyledDocument().setCharacterAttributes();. Problem is that when I use the getText() method from the textpane, the styled text is missing. For example I input a normal string into the textpane, the getText() returns the html code and the text. When I style the text and use getText() all the styled words are deleted and normal words are preserved.
What I'm trying to accomplish is, to save the entire plain text (including the html) on a text file and when I load it back up and set it on the JTextPane, it keeps its style, but for some reason styled text is deleted on the "getText()" method and normal text is preserved normally. Thanks