有没有办法调用一个CSS文件到jEditorPane? [英] Is there a way to attatch a css file to a jEditorPane?
本文介绍了有没有办法调用一个CSS文件到jEditorPane?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以附加一个CSS文件(或字符串包含
HTMLEditorKit $ c> $ c>默认情况下查找一个文件
default.css
- 我不知道在哪里。
或者,这应该工作:
StyleSheet ss = new StyleSheet();
ss.importStyleSheet(styleSheetURL);
HTMLEditorKit kit =(HTMLEditorKit)jEditorPane.getEditorKit();
kit.setStyleSheet(ss);但是,请注意,HTMLEditorKit只支持 CSS 1的com / javase / 6 / docs / api / javax / swing / text / html / CSS.htmlrel =nofollow noreferrer>有限子集。
Simple enough question: I have a string containing HTML that is being handed off to a JEditorPane for user consumption.
Can I attach a CSS file (or string containing CSS rules) to allow for more specific styling of the text?
解决方案 The HTMLEditorKit
per default looks for a file default.css
- I'm not sure where, though.
Alternatively, this should work:
StyleSheet ss = new StyleSheet();
ss.importStyleSheet(styleSheetURL);
HTMLEditorKit kit = (HTMLEditorKit)jEditorPane.getEditorKit();
kit.setStyleSheet(ss);
However, note that HTMLEditorKit only supports a limited subset of CSS 1.
这篇关于有没有办法调用一个CSS文件到jEditorPane?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文