Code example for HTMLDocument

Methods: getStyleSheet

0
		Font font = UIManager.getFont("Label.font");
		if (font == null) { // Try to make a sensible default
			font = new Font("SansSerif", Font.PLAIN, 12);
		} 
		HTMLDocument doc = (HTMLDocument) textArea.getDocument();
		doc.getStyleSheet().addRule(
				"body { font-family: " + font.getFamily() +
						"; font-size: " + font.getSize() + "pt" +
						"; color: " + Util.getHexString(fg) + "; }");
 
		// Always add link foreground rule.  Unfortunately these CSS rules 
		// stack each time the LaF is changed (how can we overwrite them 
		// without clearing out the important "standard" ones?). 
		Color linkFG = Util.getHyperlinkForeground();
		doc.getStyleSheet().addRule(
				"a { color: " + Util.getHexString(linkFG) + "; }");
 
		URL url = TipUtil.class.getResource("bullet_black.png");
		if (url!=null) {
			doc.getStyleSheet().addRule(
				"ul { list-style-image: '" + url.toString() + "'; }");
		} 
 
	}