2012-07-08 44 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);