Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java WindowMessage中的换行符_Java - Fatal编程技术网

Java WindowMessage中的换行符

Java WindowMessage中的换行符,java,Java,我是java新手,我尝试在消息字符串中添加新行: String message = "Test User1,\n Test User2,\n Test User1"; WindowMessage win2 = new WindowMessage("The following Names are duplicate : "+messages); win2.setModal(true); app.addWindow(win2); 我试图添加\r\n、\n、%r%n、%n,但它们都不起作用 在my

我是java新手,我尝试在消息字符串中添加新行:

String message = "Test User1,\n Test User2,\n Test User1";
WindowMessage win2 = new WindowMessage("The following Names are duplicate : "+messages);
win2.setModal(true);
app.addWindow(win2);
我试图添加\r\n、\n、%r%n、%n,但它们都不起作用

在my WindowMessage(扩展WindowPane)类中,消息被设置为标签:

lblMessage.setText(Message);

知道为什么吗?

不清楚您使用的是哪种API,但请尝试在html中使用
JLabel

JLabel l = new JLabel("<html>line1<br>line2</html>");

如果您无法控制可以添加多少标签,则您的库不可能执行此操作。

尝试使用

当我使用两个反斜杠时,它会在消息中显示“\n”;当我使用三个反斜杠时,它会显示“\”。对于初学者,您似乎正在为消息使用三个不同的变量名<代码>消息,
消息
消息
。也许您没有共享的一些代码会澄清这3个变量之间的任何差异。至于新行字符,您可以尝试
String message=String.format(“Test User1\n Test User2\n Test User1”)LBL消息的类型是什么?它甚至支持多行文本显示吗?导入nextap.echo.app.Label;它似乎不支持多行文本我使用EchoStudio 3,它也不支持html代码:(我无法控制我需要多少标签:(对所有人来说,感谢你们的帮助这是在本地主机上工作,但不是在我的服务器上,真的很奇怪,安全设置或jdk变体/版本有什么不同吗?我会看看的
Label line1 = ...
Label line2 = ...