• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiline JLabel?

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyway to make a JLabel multiline? I wanna display a 3 line message but I am not getting the results I want using 3 JLabels.
Thanks,
Frank
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi frank,
You want to display the 3 line message using 1 JLabel or 3 JLabels be clear???
If you want to use only one JLabel to display 3 lines it is not possible. JLable setText method supports only one line text.
Next if you want to use 3 JLabels to display 3 lines of text. It is definitely possible. Use 3 instances of JLabel and insert your required text. But you need to specify the x,y co-ordinates and specify the locations.specify x co-ordinates as same and change your y co-ords.
Use a GUI editor and place JLabel one below the other. This will help you to place the labels where ever you want and however you want to display...try JPadPro, or JBuilder,or Visual Cafe, or Visual Age...all these editors are very good to have the feel of GUI.
Good luck in the exploration of java..
lakshmi
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the answer I was looking for on JGuru.com
To achieve a multiline label all you need to do is embed html into the text of your label like this:
JLabel my_label = new JLabel("< html >line 1 < br >line 2< br >line 3< / html >");
I had to modify the html tags because they weren't being shown.
Frank
[This message has been edited by Frank Hale (edited May 29, 2000).]
[This message has been edited by Frank Hale (edited May 29, 2000).]
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic