my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes multi line in a java.awt.Label Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "multi line in a java.awt.Label" Watch "multi line in a java.awt.Label" New topic

multi line in a java.awt.Label

Cyrus Serrano
Ranch Hand

Joined: Sep 29, 2003
Posts: 137
is it possible to multi line in a java.awt.Label?

i wish to display a a sentence, the problem is the string doesnt wrap around the Label control.

Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
You can try using html tags to display the information eg

<html>my line<br>anotherline</html>
Cyrus Serrano
Ranch Hand

Joined: Sep 29, 2003
Posts: 137
sir thank you,

but i needed to display the information inside a java.awt.Label?

luc comeau
Ranch Hand

Joined: Jan 20, 2005
Posts: 97
hey cyrus, i think rachel is a woman...maybe not but anyways lol..
She was correct, a JLable can render html,soooooooo...just put that inside ur caption of the JLabel ie.
JLabel j= new JLabel("<html>First line of text <br> Second line of text</html>");

i think thats right atleast.

National Research Council<br />Internet Logic Department
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Check out the LineBreakMeasurer class. Its api includes an example.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

Joe McTigue,
Your post was moved to a new topic.

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: multi line in a java.awt.Label
It's not a secret anymore!