JEditorPane HTML rendering

I use JEditPane to display HTML text containing links and make links available. I managed to do this, but text and links are shown in ugly font and color, underlined default link, etc. Is there a way to change the default behavior of JEditPane without editing the HTML inside?

Appreciate Thanks

+3
source share
1 answer

Try adding a CSS style, for example:

JEditorPane jEditorPane = new JEditorPane();
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet styleSheet = kit.getStyleSheet();
styleSheet.addRule("A {color:red}"); //change links to red
jEditorPane.setEditorKit(kit);
+4
source

Source: https://habr.com/ru/post/1784560/


All Articles