在JTextArea中设置字体 [英] Setting fonts in a JTextArea
本文介绍了在JTextArea中设置字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JTextArea,它具有以下文本"Text1 Text2 Text3". 有没有办法使所有字体都不同?例如. 文本1"为粗体,文本2"为斜体,文本3"为正常?
I've got a JTextArea which has the following text "Text1 Text2 Text3". Is there a way I can make all of them different fonts? E.g. "Text1" is bold, "Text2" is italic and "Text3" is normal?
我知道我可以创建一个Font对象,但是只能将其应用于JTextArea对象.
I know I can create a Font object, however I can only apply it the JTextArea object.
谢谢.
推荐答案
此 .但是您可以使用JTextPane或JEditorPane.
This is not possible in JTextArea. But you can use JTextPane or JEditorPane.
这篇关于在JTextArea中设置字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文