hey all, can somebody help me out with this? i have a JTextPane formatted with a StyledDocument. characters 6-9 of the text are highlighted. after i change parts of the text, the highlight expands over the whole text. how can i make the highlight stay correct (namely at chars 6-9).
posted 9 years ago
In the JTextPane api scroll down to the section "Methods inherited from class javax.swing.JEditorPane" and find the setText method. Follow the link to the Method Detail section of the JEditorPane api. Using this method replaces all content in the StyledDocument. To allow the attributes to remain in the document use the Document method insertString.