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.


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

Results 1 to 2 of 2

Thread: How do I achieve this layout with swing? Already tried grid*Layout

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Thanked 0 Times in 0 Posts

    Default How do I achieve this layout with swing? Already tried grid*Layout

    Class project, I've written all the nuts and bolts and now it's time to write the GUI. This is hard! I'm new to Java and I've tried GridLayout and GridBagLayout but neither of them worked perfectly.

    The best way to describe what I want is with an image:

    I have a menu/control panel on the left, which I want to take up 1/3 (give or take) of the frame. The remainder of the frame will be filled with the display window. When the frame is resized, I want the display window to "sacrificially" resize so that the control panel keeps its size. Until the user minimises the frame so much that there is no longer any room for the control panel - then it (the control panel) can start getting smaller. I know how to achieve this using QT, but I'm having trouble doing it with swing.

    I think the image is clearer than by description.

    Thoughts on best way to achieve this? Cheers.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: How do I achieve this layout with swing? Already tried grid*Layout

    You can nest layouts. And you can set the minimum and maximum size of a component. I'd try a BorderLayout or a BoxLayout, along with setting the minimum and maximum size of the JPanel you want to keep the same size.
    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. 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
  2. Layout manager
    By kurt-hardy in forum AWT / Java Swing
    Replies: 3
    Last Post: January 19th, 2011, 10:25 AM
  3. How to align the items in a form (grid layout)?
    By onlybarca in forum AWT / Java Swing
    Replies: 4
    Last Post: November 27th, 2010, 11:38 PM
  4. Replies: 0
    Last Post: November 27th, 2010, 10:47 PM
  5. My Custom Layout (VERY EASY TO USE)
    By aussiemcgr in forum AWT / Java Swing
    Replies: 10
    Last Post: August 5th, 2010, 01:37 PM