特定の単語や行のスタイル (フォント、色、その他の属性) を変更する必要があります。私はJTextPane
で
これを試しました:
textPane.getStyledDocument().setCharacterAttributes(start,length,myTextStyle,false);
JEditorPaneで同じことを行う方法はありますか。JEditorPane
で単語をフォーマットするにはどうすればよいですか。
特定の単語や行のスタイル (フォント、色、その他の属性) を変更する必要があります。私はJTextPane
で
これを試しました:
textPane.getStyledDocument().setCharacterAttributes(start,length,myTextStyle,false);
JEditorPaneで同じことを行う方法はありますか。JEditorPane
で単語をフォーマットするにはどうすればよいですか。
スタイル付きドキュメントにキャストする
((StyledDocument)editorPane.getDocument()).setCharacterAttributes(start,length,myTextStyle,false);
HTMl または RTF テキストを使用して、JEditorPane 内のテキストをフォーマットできます。
これを行う方法についての良い説明があります @ http://docs.oracle.com/javase/tutorial/uiswing/components/text.html
「JEditorPane」という名前は誤解を招きやすいので注意してください。JTextPane
のサブクラスですJEditorPane
。したがって、独自のスタイルのエディターを作成する場合は、JTextPane
.