2012-07-08 40 views
0

相對自我解釋,我如何在JTextPane中居中選定的文本?如何對齊JTextPane中的選定文本?

(對齊的任何文本是有用)

+0

[居中在JTextArea或文本的JTextPane - 水平文本對齊]的可能重複(HTTP://計算器。 COM /問題/ 3213045 /定心文本-IN-A-的JTextArea或 - 的JTextPane水平文本對準) – tenorsax 2012-07-08 18:02:31

回答

3

實測值上coderanch一些代碼:

 SimpleAttributeSet attribs = new SimpleAttributeSet(); 
StyleConstants.setAlignment(attribs , StyleConstants.ALIGN_CENTER); 
pane.setParagraphAttributes(attribs,true);