问题描述
|
我已经用setText函数设置了
JTextArea
的文本
abc=\"PREFIX table: <http://www.daml.org/2003/01/periodictable/PeriodicTable#> \" +
\"SELECT ?name \" +
\"FROM <http://www.daml.org/2003/01/periodictable/PeriodicTable.owl>\" +
\"WHERE {\" +
\" ?element table:name ?name. \" +
\" FILTER(str(?name)=\\\"sodium\\\") \" +
\" }\"
texta.setText(abc);//abc is very long string
如何在JTextArea
中显示带有换行符和间距的字符串。
解决方法
abc=\"PREFIX table: <http://www.daml.org/2003/01/periodictable/PeriodicTable#>\\n\" +
\"SELECT ?name\\n\" +
\"FROM <http://www.daml.org/2003/01/periodictable/PeriodicTable.owl>\\n\" +
\"WHERE {\\n\" +
\" ?element table:name ?name.\\n\" +
\" FILTER(str(?name)=\\\"sodium\\\")\\n\" +
\" }\"
那应该工作。
,在字符串中使用换行符。 \'\\n\'
字符。