如何填充 JTextPane
我有一个字符串数组,想将它们一一添加到 JTextPane 中,每个字符串都用新行分隔。我将如何实现这一目标?
I have an array of string and would like to add them one by one to the JTextPane
, each of which to be separated by a new line. How would I go about achieving this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先创建以“\n| 字符作为分隔符的行。第二次调用
First create line with "\n| chars as separators. Second call
使用系统属性换行:
编辑:我在中找到旧线程,提到了该属性的用法<一href="http://docs.oracle.com/javase/7/docs/api/javax/swing/text/DefaultEditorKit.html#EndOfLineStringProperty" rel="nofollow">EndOfLineStringProperty,这是有道理的,因为
JTextPane
扩展了使用文档的JEditorPane
。我会尝试一下。另外,在 JTextPane 文档 中,写有:Use the system property for new line:
Edit: I found in an old thread, that mentions the usage of the property EndOfLineStringProperty, which makes sense, since the
JTextPane
extendsJEditorPane
which uses a document. I would give that a shot. Also, in the JTextPane docs, is written: