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.
使用 JTextArea,我希望第一行是一个简单的文本(JTextArea 的标题)。
有没有办法让文本中心在第一行对齐?
我不认为你可以用一个简单的JTextArea. 您可能会考虑切换到JTextPane支持 HTML 标记的 . Java 教程如何使用编辑器窗格和文本窗格显示了一个示例。
JTextArea
JTextPane
或者,您可以在显示标题文本的位置JLabel上方添加一个。JTextArea
JLabel