开发者

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:

  1. <u> - wavy underline
  2. <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'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜