2012-02-16 49 views

回答

1

首先创建为“\ n行。|字符作为分隔符的第二个电话

textPane.getDocument().insertString(textPane.getDocument().getLength(), theSumOfStrings, new SimpleAttributeSet()); 
1

使用system property新行:

String separator = System.getProperty("line.separator"); 
StringBuilder sb = new StringBuilder(); 
for (String s : myStringArray) { 
    sb.append(s + separator); 
} 
myTextPane.setText(sb.toString()); 

编辑:我在old thread,即提到财产EndOfLineStringProperty,这是有道理的使用中发现,由于JTextPane延伸JEditorPane它使用的文件。我会给那一枪。此外,在JTextPane docs,写的是:

对于讨论如果处理换行,请参阅DefaultEditorKit。

+0

上面的代码添加文字,但每根弦不放在一个单独的行 – 2012-02-16 23:38:46

+0

@SolerMani - 见编辑,希望它有帮助 – MByD 2012-02-16 23:52:48

+0

感谢所有的帮助,但仍然无法使它工作 – 2012-02-16 23:56:44