在JEditorPane中文本格式

问题描述 投票:0回答:3

我需要改变风格特定单词或线(即字体,颜色等属性)。 我曾与JTextPane的作为尝试这样:

textPane.getStyledDocument().setCharacterAttributes(start,length,myTextStyle,false);

有没有办法做同样的事情的JEditorPane。 我怎样才能格式化JEditorPane中的一句话。

java swing jeditorpane
3个回答
3
投票

它投射到样式文件

((StyledDocument)editorPane.getDocument()).setCharacterAttributes(start,length,myTextStyle,false);

1
投票

您可以使用HTML或RTF文本到一个JEditorPane中的文本格式。

这里是如何做到这一点@ http://docs.oracle.com/javase/tutorial/uiswing/components/text.html一个很好的解释


1
投票

心灵,命名“的JEditorPane”是一种误导; JTextPaneJEditorPane的子类。所以,如果你想使自己的风格的编辑器,使用JTextPane

© www.soinside.com 2019 - 2024. All rights reserved.