开发者

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

开发者 https://www.devze.com 2022-12-09 06:14 出处:网络
I have made a 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.

I have made a 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.

How can I display that message?

开发者_Python百科

Is there any property of JLabel which we can set to display the multiple line message?

Will I have to use several JLabels for multiple lines?

Is there any other way I can display that message?


How to Use HTML in Swing Components

Displaying Multi Line Text


You can do

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

and it will automatically wrap it where appropriate.

0

精彩评论

暂无评论...
验证码 换一张
取 消