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: JLables

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JLables

    Hey guys - this is my first post

    I currently have a JFrame, which has a center, north, south, east and west panels. My question is this; can I create a multiline JLabel for the North Panel, that has text on the top and a text box below it? I know I can use HTML to have multiline text for a JLabel, however I want my second line to be a text box. Any ideas?


    label = new JLabel("<HTML> <center> <font size = 18> Enter your Search Below </font> <BR> </HTML>"( I WANT A TEXT BOX HERE));


    Thanks guys!

  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: JLables

    Have you tried the add method which is inherited from Container?
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JLables

    Yes, however the 2nd add will always overwrite the first.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JLables

    Nest your layouts. Create a JPanel with a particular Layout - for instance a BoxLayout with a PAGE_AXIS - and add the JLabel and JTextField (I presume this is what you mean by 'text box'), then add this JPanel to your main panel.