aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JLabel and JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JLabel and JScrollPane" Watch "JLabel and JScrollPane" New topic
Author

JLabel and JScrollPane

Cyrus Serrano
Ranch Hand

Joined: Sep 29, 2003
Posts: 137
hello,

can i display multiple line of text using a JLabel. Or do i need to paste the JLabel within a JScrollPane?

thanks
Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
You can use this method...

JLabel myLabel = new JLabel("<HTML> My Label text<br>Goes here</HTML>");

Cheers,
Rachel
Cyrus Serrano
Ranch Hand

Joined: Sep 29, 2003
Posts: 137
thanks mam rachel,

but is there any propoerties on JLabel that could multiline the text to be shown on that object, im sorry to compare it on Visual Basics Label object. thanks mam.

im currently trying to Quiz program, questions are displayed on label objects, problem is , it just display a single line. help..

Cyrus
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
You could use an non-editable JTextArea and make it look like a label. JTextArea supports word-wrap
Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
That's a much easier solution to use. In our project we are reading label definitions from a properties file that contains different translations at using a text area is far easier than the HTML label because we can't be sure of the size of thing that we have to fit onto the label.

Cheers,
Rachel
 
 
subject: JLabel and JScrollPane