JEditorPane HTML rendering
I am using a JEditPane to render an HTML text that contains links, and make the links clickable. I have managed to do that but the text and the links are shown in an ugly font and color, the default blue underlined link, etc. I开发者_如何转开发s there a way to change the default behavior of the JEditPane without editing the HTML inside?
Appreciate the help Thanks
Try adding a CSS style, like this:
JEditorPane jEditorPane = new JEditorPane();
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet styleSheet = kit.getStyleSheet();
styleSheet.addRule("A {color:red}"); //change links to red
jEditorPane.setEditorKit(kit);
精彩评论