Java HTML renderer with custom HTML tags view
I have task to implement HTML renderer. That's ok, i have used javax.swing.text.html.HTMLDocument
.
Now i have to implement custom view for HTML tags:
<u>
- wavy underline<b>
- usual bold style + text shadow
I've tried:
pane = new JTextPane();
pane.setEditable(false);
add(new JScrollPane(pane));
StyledEditorKit kit = new HTMLEditorKit() {
public Document createDefaultDocument() {
HTMLDocument doc = new CustomHTMLDocument(getStyleSheet());
StyleSheet sheet = doc.getSty开发者_运维知识库leSheet();
sheet.addRule("b {text-shadow: #6374AB 14px -6px 2px; }");
return doc;
}
};
pane.setEditorKit(kit);
But this doesn't work. Can anybody help me with this ?
Try this to add your own custom tag in the HTMLEditorKit http://java-sl.com/custom_tag_html_kit.html
Swing's HTML/CSS rendering is extremely basic. I am not surprised that it supports neither of the 'wavy underline' nor 'text shadow'.
精彩评论