In my application, I use JTextPane to display some log data. Since I want to pin some specific lines in this text (for example, error messages), I set the contentType to " text/html ". That way I can format the text.
Now I create a JButton that copies the contents of this JTextPane to the clipboard. This part is simple, but my problem is that when I call myTextPane.getText() , I get HTML code, for example:
<html> <head> </head> <body> blabla<br> <font color="#FFCC66"><b>foobar</b></font><br> blabla </body> </html>
instead of getting only raw content:
blabla foobar blabla
Is there a way to get only the text of my JTextPane as plain text? Or do I need to convert HTML to source?
java swing jtextpane
romaintaz
source share