I haven’t used HTML in JTextPane before and playing with this today. I come across with strange output.
Here is my simple code, htmlStr contains contains a tag <aa> :
public class HtmlInJTextPaneTest extends JFrame {
private JTextPane jtp;
private String htmlStr= "<html><body><b>What is this</b> <aa > ?? </body></html>";
public HtmlInJTextPaneTest() {
jtp = new JTextPane();
jtp.setContentType("text/html");
jtp.setText(htmlStr);
//jtp.setEditable(false);
//jFrame setup
add(jtp);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(200, 100);
setVisible(true);
}
public static void main(String[] args) {
new HtmlInJTextPaneTest();
}
}
The output of this is :

I don’t know why the box (seems like input field) appeared with tag name aa in it?
It disappears when I set editable false on JTextPane object jtp.
jtp.setEditable(false);
Can you please explain it?
You can use this http://java-sl.com/custom_tag_html_kit.html as example of custom tag support in
HTMLEditorKit.