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 中居中选定文本?
(对齐任何文本都有帮助)
在 coderanch 上找到了一些代码:
SimpleAttributeSet attribs = new SimpleAttributeSet(); StyleConstants.setAlignment(attribs , StyleConstants.ALIGN_CENTER); pane.setParagraphAttributes(attribs,true);