• Post Reply Bookmark Topic Watch Topic
  • New Topic

Formatted text pane problem

 
Lukas Benberg
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).

thank you!

 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lukas Benberg
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank! that was very helpful!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!