Thursday, July 12, 2007

Wrapping Text In JLabels

I recently picked up Swing while I was developing Tweeter!, a Java client for Twitter. A nifty little trick that I found out about was how to wrap the text inside a JLabel.

JLabels support HTML markup. So all you need to do is surround the text with HTML tags ( <html> and </html> ) and voila! The contents wrap around! If you need it to be centered, simply add a <center> tag. It's that simple!

No comments: