java JEditorPane将某些样式变为蓝色
我一直在使用JEditorPane,试图显示CSS,但它似乎没有正确地显示CSS。看看其他例子,它似乎应该是正确的,但似乎渲染不正确。据我所知,CSS和swing不起作用。。。我们相处得很好
这就是我目前正在努力做的:
// List variables...
public JEditorPane diff_view = new JEditorPane();
public static HTMLEditorKit kit = new HTMLEditorKit();
public static StyleSheet ss = kit.getStyleSheet();
public Frame() {
// Adding a list...
try {
ss.importStyleSheet(new URL("http://slot1.wikia.com/load.php?debug=true&lang=en&"
+ "modules=mediawiki.action.history.diff&only=styles"));
} catch (MalformedURLException ex) { }
JScrollPane jsp2 = new JScrollPane(diff_view);
jsp2.setSize(909, 650);
jsp2.setLocation(153, 100);
diff_view.setContentType("text/html");
diff_view.setEditable(false);
diff_view.setLocation(153, 100);
diff_view.setSize(909, 650);
diff_view.setEditorKit(kit);
add(diff_view);
}
// Retrieving the pages..
没有出现错误,只是一个蓝色的编辑器窗格。以下是最初检索到的内容:http://runescape.wikia.com/index.php?diff=prev&oldid=7886038&diffonly=1&action=render
我应该尝试更改样式表、jeditorpane还是其他什么
为了清晰起见,下面是一张正在发生的事情的图片:
# 1 楼答案
JEditorPane
对样式的支持有限。你可以试试,例如https://code.google.com/p/flying-saucer/# 2 楼答案
你不应该用jeditorpane来做这个