2012-02-16 47 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