Results 1 to 9 of 9
  1. #1
    SNPTT is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Default JLabel new line?

    Hi, I'm just wondering how i can extend my JLabel so it goes onto a new line underneath.
    I have a set size window and label that i must use and at the moment it just goes along in a straight line and i cant see any of it.
    Sounds like a stupid question i know, but i have no idea haha
    Thanks

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,936
    Rep Power
    19

    Default

    Someon might correct me here, but isn't JLabel single line only?

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Correction! You can use html to get more lines:
    Java Code:
    jLabel1.setText("<html>Line1<br>Line2</html>");
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,936
    Rep Power
    19

    Default

    You learn something new everyday...:)

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,434
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Tolls View Post
    You learn something new everyday...:)
    That html trick also works for tooltips.

    kind regards,

    Jos

  6. #6
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,936
    Rep Power
    19

    Default

    How much HTML can it translate?

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,434
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Tolls View Post
    How much HTML can it translate?
    All of html 3.2 and a bit of 4.0; it does understand css files (and embedded in the html) but, of course, a label can't do hrefs (of course Camickr will prove me wrong here ;-)

    kind regards,

    Jos

  8. #8
    SNPTT is offline Member
    Join Date
    May 2010
    Posts
    9
    Rep Power
    0

    Talking

    Quote Originally Posted by PhHein View Post
    Correction! You can use html to get more lines:
    Java Code:
    jLabel1.setText("<html>Line1<br>Line2</html>");
    Awesome, thanks alot, this has really helped :D

  9. #9
    goffy is offline Member
    Join Date
    Apr 2010
    Location
    Cambridge
    Posts
    30
    Rep Power
    0

    Default

    Quote Originally Posted by PhHein View Post
    Correction! You can use html to get more lines:
    Java Code:
    jLabel1.setText("<html>Line1<br>Line2</html>");
    Thanks alot, i never knew this!
    I will surely use that next time i need to :o

Similar Threads

  1. Adding a JLabel to a JPanel - jlabel not showing
    By Bongeh in forum New To Java
    Replies: 17
    Last Post: 04-06-2010, 11:02 PM
  2. Replies: 4
    Last Post: 09-10-2009, 10:18 AM
  3. Replies: 9
    Last Post: 04-07-2009, 03:51 AM
  4. Make a text in Jlabel down to next Line
    By hungleon88 in forum AWT / Swing
    Replies: 2
    Last Post: 12-01-2008, 11:10 PM
  5. Reading in data from file line by line
    By bluekswing in forum New To Java
    Replies: 1
    Last Post: 10-02-2007, 12:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •