开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜