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: Layout Managers

  1. #1
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Layout Managers

    I have read the API and looked at examples but its not answering my question. Which layout would treat a panel as its own entity. Meaning if I made a method that made a matrix of buttons using GridLayout and returned that panel. Then called the method onto a frame and the buttons would not spread out all over the frame. They would simply stop at the dimensions of the panel.

    Am I looking for something that is not possible?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 Posts

    Default Re: Layout Managers

    Am I looking for something that is not possible?
    Of course not. A JPanel is always its own entity.

    The JPanel's layout manager will be a GridLayout, the JFrame's layout manager would be fine as the default BorderLayout, depending on what else you're adding to it. Set the preferred size of the JPanel, add it to the JFrame, pack() the JFrame, set the JFrame visible. If this is not working for you, post your code.

  3. #3
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Layout Managers

    Just had a lesson on pack that I won't forget... Thanks again, spent hours on this simple task for it to be answered by a simple four lettered word. Another four letter word comes to mind as I wrote that.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 Posts

    Default Re: Layout Managers

    Just had a lesson on pack that I won't forget...
    Unpleasant, but hopefully true. You're welcome.

Similar Threads

  1. Layout Managers
    By jason3460 in forum AWT / Java Swing
    Replies: 2
    Last Post: December 4th, 2013, 06:05 PM
  2. GUI Layout - Does anyone know how to set a layout?
    By mikemontesa in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 20th, 2013, 04:35 PM
  3. Is there a layout for this?
    By gkffjcs in forum AWT / Java Swing
    Replies: 2
    Last Post: September 27th, 2011, 09:15 AM
  4. Replies: 1
    Last Post: April 14th, 2011, 07:50 AM
  5. Grid bag layout inside grid bag layout
    By kiddkoder in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 29th, 2011, 08:07 AM