OleksandrBezhan
OleksandrBezhan

Reputation: 31

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.getStyleSheet();
        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 ?

Upvotes: 2

Views: 759

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168825

Swing's HTML/CSS rendering is extremely basic. I am not surprised that it supports neither of the 'wavy underline' nor 'text shadow'.

Upvotes: 1

StanislavL
StanislavL

Reputation: 57381

Try this to add your own custom tag in the HTMLEditorKit http://java-sl.com/custom_tag_html_kit.html

Upvotes: 1

Related Questions