In my application, I use a JTextPane to display some log information. As I want to hightlight some specific lines in this text (for example the error messages),
You need to do it yourself unfortunately. Imagine if some of the contents was HTML specific, eg images - the text representation is unclear. Include alt text or not for instance.