Results 1 to 6 of 6
  1. #1
    Daslee's Avatar
    Daslee is offline Member
    Join Date
    Mar 2012
    Location
    Plunge, Lithuania
    Posts
    36
    Rep Power
    0

    Default JFrame each component in new line and new line in JLabel

    Hello. How i can make my every component in JFrame to be in new line after doing JFrame.add(component)? Now if just length is almost as width, so just then other component will be in new line.
    And how i can make new line in JLabel text something like that: "1 Line<br>2 Line"?

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

    Default Re: JFrame each component in new line and new line in JLabel

    Maybe a GridLayout can solve your JComponent placement; w.r.t. multiple lines in your JLabel, try the following text: "<html>1 Line<br>2 line</html>".

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Daslee's Avatar
    Daslee is offline Member
    Join Date
    Mar 2012
    Location
    Plunge, Lithuania
    Posts
    36
    Rep Power
    0

    Default Re: JFrame each component in new line and new line in JLabel

    Quote Originally Posted by JosAH View Post
    Maybe a GridLayout can solve your JComponent placement; w.r.t. multiple lines in your JLabel, try the following text: "<html>1 Line<br>2 line</html>".

    kind regards,

    Jos
    New line in JLabel worked, but GridLayout made my components height as form height and every component width: form width / components

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

    Default Re: JFrame each component in new line and new line in JLabel

    Quote Originally Posted by Daslee View Post
    New line in JLabel worked, but GridLayout made my components height as form height and every component width: form width / components
    You didn't say that you didn't want that. Try a BoxLayout or a GridBagLayout or even better, study how LayoutManagers work in general.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Daslee's Avatar
    Daslee is offline Member
    Join Date
    Mar 2012
    Location
    Plunge, Lithuania
    Posts
    36
    Rep Power
    0

    Default Re: JFrame each component in new line and new line in JLabel

    Quote Originally Posted by JosAH View Post
    You didn't say that you didn't want that. Try a BoxLayout or a GridBagLayout or even better, study how LayoutManagers work in general.

    kind regards,

    Jos
    Thanks for help. :)

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: JFrame each component in new line and new line in JLabel

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 16
    Last Post: 09-17-2011, 02:41 AM
  2. Replies: 2
    Last Post: 07-02-2010, 02:20 PM
  3. JLabel new line?
    By SNPTT in forum New To Java
    Replies: 8
    Last Post: 05-19-2010, 11:24 AM
  4. Replies: 4
    Last Post: 09-10-2009, 10:18 AM
  5. 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

Posting Permissions

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