make a JLabel wrap it's text by setting a max width

后端 未结 9 2598
清酒与你
清酒与你 2020-11-29 08:09

I have a JLabel which has a lot of text on it. Is there a way to make the JLabel have a max width so that it will wrap the text to make it not exceed this width?

Tha

9条回答
  •  一个人的身影
    2020-11-29 08:29

    Yes there are two similar ways (first with css style="width:...px", second with html WIDTH=.......:

    1.

    labelText = String.format("
    %s
    ", width, text);

    2.

    labelText = String.format("
    %s
    ", width, text);

提交回复
热议问题