简体   繁体   English

如何在Java GUI上添加多行标签?

[英]How to add multi-line label on a Java GUI?

I have made a java swing GUI. 我做了一个java swing GUI。 Now I want to display a static message on that but the message is multi-line and the JLabel is single line. 现在我想在其上显示静态消息,但消息是多行的,JLabel是单行。

How can I display that message? 如何显示该消息?

Is there any property of JLabel which we can set to display the multiple line message? 是否有JLabel的任何属性我们可以设置显示多行消息?

Will I have to use several JLabels for multiple lines? 我是否必须为多条线路使用多个JLabel?

Is there any other way I can display that message? 有没有其他方法可以显示该消息?

You can do 你可以做

JLabel l = new JLabel("<html><p>Hello World! blah blah blah</p></html>");

and it will automatically wrap it where appropriate. 它会在适当的时候自动包装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM