Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: JLablel with more than one line

  1. #1
    Junior Member keep smiling's Avatar
    Join Date
    Oct 2011
    Location
    Italy
    Posts
    14
    My Mood
    Cool
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question JLablel with more than one line

    how can i make many lines in a JLable ?
     JLabel text = new JLabel("Worg input!");

    i tried to use /n but it doesn't work

    any ideas
    Last edited by keep smiling; May 23rd, 2012 at 12:06 PM.
    Java lover


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,620
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Re: JLablel with more than one line

    You need to use html tags. For example:
    JLabel text = new JLabel("<html>Worg<br>input!</html>");  //I'm not sure if the new line tag is <br> or </br>

    That should make a JLabel with the text on two different lines.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. The Following User Says Thank You to aussiemcgr For This Useful Post:

    keep smiling (May 23rd, 2012)

  4. #3
    Junior Member keep smiling's Avatar
    Join Date
    Oct 2011
    Location
    Italy
    Posts
    14
    My Mood
    Cool
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: JLablel with more than one line

    i haven't seen something like this before but it works thanks
    Java lover

  5. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,283
    My Mood
    Hungover
    Thanks
    142
    Thanked 620 Times in 531 Posts

    Default Re: JLablel with more than one line

    Quote Originally Posted by keep smiling View Post
    i tried to use /n but it doesn't work
    If anything it would have been \n.

    Quote Originally Posted by aussiemcgr View Post
    //I'm not sure if the new line tag is <br> or </br>
    It's <br>, or more correctly, <br/>. HTML br tag
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 10
    Last Post: September 16th, 2011, 07:49 PM
  2. Reading a file line by line using the Scanner class
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  3. Reading a file line by line using the Scanner class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  4. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM