How can I enable the JLabel to show the whole paragraph?
JLabel label = new JLabel("<html>"+test+"</html>");
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With