Hi. I currently use a JTextArea to display my text and I can highlight certain portions of it using a the Highlighter class. However, when I switch to a JEditorPane and display HTML I run into some problems.
When I highlight the text, I do it based on the index of the characters (for example, highlight characters 10-20). When I switched to the JEditorPane, these highlights do not highlight the same places any more (even when I don't have any HTML being displayed). Can someone explain to me why this is happening and how I might go about highlighting the correct indices in the JEditorPane?
Thank you. Jeff Storey
posted 9 years ago
It's kind of hard to answer without more information. You might post some code.
I'm kind of confused why you mention HTML here. JEditorPane can display HTML (using the HTMLEditorKit) but can also display other kinds of formatted text. If you don't need to actually mess with HTML or RTF or something like that, you may want to use a JTextPane instead. (JTextPane happens to be a subclass of JEditorPane.)