JAVA-在JEditorPane中设置selectedtext的字体 [英] JAVA - set font of selectedtext in a JEditorPane
本文介绍了JAVA-在JEditorPane中设置selectedtext的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在JEditorPane中设置字体/粗体/斜体/下划线?
How can I set the font/bold/italic/underline whatever of some text in a JEditorPane?
我正在尝试创建一个简单的文档编辑器,但是我只能弄清楚如何设置ENTIRE JEditor/JText窗格的字体/粗体/斜体/任何内容.
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.
首选RTF,也可以使用HTML.
RTF is preferred, HTML is fine as well.
推荐答案
JEditorPane.getDocument()返回StyledDocument的实例. StyledDocument具有
JEditorPane.getDocument() returns an instance of StyledDocument. StyledDocument has setCharacterAttributes() method to set the font properties.
这篇关于JAVA-在JEditorPane中设置selectedtext的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文