gpt4 book ai didi

label - 瓦丁 : My label ignores the carriage return character

转载 作者:行者123 更新时间:2023-12-04 17:26:15 25 4
gpt4 key购买 nike

我有一个包含换行符(“\r”)的传入文本字符串。

当我输出它时: System.out.println(myString) , 回车被解释。

但是,当我将字符串设置为标签的内容时,它会忽略回车。

如何强制标签解释回车/换行(没有 XHTML 模式)?

最佳答案

您可以通过以下方式将此文本放入标签中:

@Override
public void init() {
Window window = new Window();
Label label = new Label("<pre>First line\rSecond line\nThird line</pre>", Label.CONTENT_XHTML);
window.addComponent(label);
setMainWindow(window);
}

关键是使用 Label.CONTENT_XHTML 内容模式并将文本括在 <pre> 中标签。

关于label - 瓦丁 : My label ignores the carriage return character,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8818104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com