Code example for HTMLDocument

Methods: getStyleSheetsetBase

0
        SwingUtils.setPopupMenu(textPane, new JTextPanePopupMenu(textPane));
  
        final HTMLDocument document = (HTMLDocument) this.textPane.getDocument();
 
        // Set the base URL of the text pane 
        document.setBase(Main.class.getResource("templates/"));
         
        // Modify the body style so it matches the system font 
        final Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + 
            "; font-size: " + font.getSize() + "pt; }";
        document.getStyleSheet().addRule(bodyRule);                
         
        final JScrollPane scrollPane = new JScrollPane(textPane);
        add(scrollPane);
 
        redraw(); 
    } 
 
    /**