This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JLabel multiline text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JLabel multiline text" Watch "JLabel multiline text" New topic

JLabel multiline text

tadi raja
Ranch Hand

Joined: Jul 07, 2008
Posts: 109
I have a doubt regarding JLabel,i want to show the text in 2 lines
using JLabel, that means multiline text.i have some web services methods
and if i call that methods that text will store in JLabel,if that methods
containing large text,i was storing only small amount of text and
remaining text could be not shown in single line,now i want to implement
in multiline text using lbl.setMaximumSize() method,but this is not
working.please provide me any solution regarding this issue.

Thank you in advance

raja ramesh
Melki Joe

Joined: Aug 29, 2008
Posts: 24
You can try using html tags fot the text to be shown in JLabel. So that the <br> tag will help for next line.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41104
And if the text is too long, try wrapping the JLabel in a JScrollPane.
It is sorta covered in the JavaRanch Style Guide.
subject: JLabel multiline text