Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JTextPaneをRTF として保存する際に問題が発生しました。位置合わせは保存されません。
JTextPane
保存する前に中央揃えを検索し、 center などのタグを追加できれば、JTextPaneドキュメントを開いたときに段落の書式設定を適切に設定できます。
JTextPane中央/右のテキスト配置を検索するにはどうすればよいですか?
あなたDocumentを取得し、にキャストしますDefaultStyledDocument。次に、getParagraphElement()メソッドを使用して、段落の先頭からのオフセットを取得します。段落の配置を確認し、段落StyleConstants.getAlignment()の属性を渡しますElement。次に、段落の終了オフセットを使用して次の段落を取得します。
Document
DefaultStyledDocument
getParagraphElement()
StyleConstants.getAlignment()
Element