Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JLabel doesn't show a long paragraph

String Text

Window

How can I enable the JLabel to show the whole paragraph?

like image 611
kk-dev11 Avatar asked May 07 '12 07:05

kk-dev11


2 Answers

JLabel label = new JLabel("<html>"+test+"</html>");
like image 132
Bitmap Avatar answered Oct 04 '22 05:10

Bitmap


The JLabel component is usually used for short pieces of text. If you need to throw in large amounts of texts, you should use the JTextArea. Once you use that, you can then wrap the text using the setLineWrap:

Sets the line-wrapping policy of the text area. If set to true the lines will be wrapped if they are too long to fit within the allocated width.

If you still want to go ahead with the usage of a JLabel (not recommended), setting the size of the label should do the trick for you.

like image 34
npinti Avatar answered Oct 04 '22 03:10

npinti