// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import java.util.Objects;
import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new GridLayout(2, 1));
    String html = "<html><h2>H2</h2>text<ul><li>list: %s</li></ul></html>";

    JEditorPane editor0 = makeEditorPane();
    editor0.setText(String.format(html, "Default"));

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    String url = Objects.toString(cl.getResource("example/bullet.png"), "null");
    JEditorPane editor1 = makeEditorPane();
    HTMLEditorKit htmlEditorKit = (HTMLEditorKit) editor1.getEditorKit();
    StyleSheet styleSheet = htmlEditorKit.getStyleSheet();
    styleSheet.addRule(String.format("ul{list-style-image:url(%s);margin:0px 20px;}", url));
    editor1.setText(String.format(html, "bullet.png"));

    // styleSheet.addRule("ul{list-style-type:circle;margin:0px 20px;}");
    // styleSheet.addRule("ul{list-style-type:disc;margin:0px 20px;}");
    // styleSheet.addRule("ul{list-style-type:square;margin:0px 20px;}");
    // styleSheet.addRule("ul{list-style-type:decimal;margin:0px 20px;}");

    // Pseudo-element is not supported in javax.swing.text.html.CSS
    // styleSheet.addRule("ul{list-style-type:none;margin:0px 20px;}");
    // styleSheet.addRule("ul li:before{content: "\u00BB";}");

    add(new JScrollPane(editor0));
    add(new JScrollPane(editor1));
    setPreferredSize(new Dimension(320, 240));
  }

  private static JEditorPane makeEditorPane() {
    JEditorPane editorPane = new JEditorPane();
    editorPane.setContentType("text/html");
    editorPane.setEditable(false);
    return editorPane;
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(MainPanel::createAndShowGui);
  }

  private static void createAndShowGui() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
      ex.printStackTrace();
      Toolkit.getDefaultToolkit().beep();
    }
    JFrame frame = new JFrame("@title@");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.getContentPane().add(new MainPanel());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
}

@@ -129,20 +129,15 @@
 ava.
-util.Objects
+net.URL
 ;%0Aim
@@ -152,24 +152,59 @@
 ax.swing.*;%0A
+import javax.swing.text.EditorKit;%0A
 import javax
@@ -632,38 +632,18 @@
     
-String
+URL
  url = 
-Objects.toString(
 cl.g
@@ -678,19 +678,11 @@
 ng%22)
-, %22null%22)
 ;%0A
+%0A
     
@@ -725,20 +725,16 @@
 ();%0A    
-HTML
 EditorKi
@@ -739,64 +739,152 @@
 Kit 
-htmlEditorKit = (HTMLEditorKit) editor1.getEditorKit();%0A
+kit = editor1.getEditorKit();%0A    if (kit instanceof HTMLEditorKit && url != null) %7B%0A      HTMLEditorKit htmlEditorKit = (HTMLEditorKit) kit;%0A  
     
@@ -934,24 +934,26 @@
 yleSheet();%0A
+  
     styleShe
@@ -1037,65 +1037,11 @@
 ));%0A
+%0A
   
-  editor1.setText(String.format(html, %22bullet.png%22));%0A%0A
     
@@ -1106,32 +1106,34 @@
 x 20px;%7D%22);%0A    
+ 
+ 
 // styleSheet.ad
@@ -1176,32 +1176,34 @@
 n:0px 20px;%7D%22);%0A
+  
     // styleShee
@@ -1256,32 +1256,34 @@
 x 20px;%7D%22);%0A    
+ 
+ 
 // styleSheet.ad
@@ -1342,16 +1342,18 @@
 );%0A%0A    
+  
 // Pseud
@@ -1408,16 +1408,18 @@
 tml.CSS%0A
+  
     // s
@@ -1482,24 +1482,26 @@
 px;%7D%22);%0A    
+  
 // styleShee
@@ -1542,24 +1542,86 @@
 %5Cu00BB%22;%7D%22);
+%0A    %7D%0A    editor1.setText(String.format(html, %22bullet.png%22));
 %0A%0A    add(ne

add instanceof check