[英]JAVA - set font of selectedtext in a JEditorPane
How can I set the font/bold/italic/underline whatever of some text in a JEditorPane? 如何在JEditorPane中设置字体/粗体/斜体/下划线?
I am trying to create a simple document editor, but i can only figure out how to set the font/bold/italic/whatever of the ENTIRE JEditor/JText pane. 我试图创建一个简单的文档编辑器,但是我只能弄清楚如何设置ENTIRE JEditor / JText窗格的字体/粗体/斜体/字体。
RTF is preferred, HTML is fine as well. RTF是首选,HTML也可以。
JEditorPane.getDocument() returns an instance of StyledDocument. JEditorPane.getDocument()返回StyledDocument的实例。 StyledDocument has setCharacterAttributes () method to set the font properties.
StyledDocument具有setCharacterAttributes ()方法来设置字体属性。
Related example: http://www.java2s.com/Code/JavaAPI/javax.swing/JTextPanesetCharacterAttributesAttributeSetattrbooleanreplace.htm 相关示例: http : //www.java2s.com/Code/JavaAPI/javax.swing/JTextPanesetCharacterAttributesAttributeSetattrbooleanreplace.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.