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 3 of 3

Thread: Need a Layout Manager that can change size of window

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

    Default Need a Layout Manager that can change size of window

    I am creating a window that contains a number of drop-downs. When the user changes the value in one of these drop-downs (Projects), I need to reload the values listed in another one (Documents). I am currently using GridLayout, but when the Documents drop-down expands, the window doesn't expand with it, thus cutting it off at the original window's size. Is there a particular layout manager that will resize the window to the proper width necessary?

    Chris

  2. #2
    Member
    Join Date
    Apr 2014
    Posts
    92
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: Need a Layout Manager that can change size of window

    GridLayout ensures that each cell is the same width & height as the others. Sounds like part of what you need is a layout manager that honors your components' preferred sizes. GridBagLayout is one that does that.

    Now, if you want the window itself (JFrame, JDialog) to resize, I don't think any layout manager will do that for you automatically. Layout managers do stuff with child components, but do nothing to the parent window. You'll probably have to run through all the window's child components, adding up their preferred widths & heights, and resize (and re-center on screen) the window yourself.

    Personally though, I would try to steer away from changing the size of the window. This seems like something that could be distracting and unintuitive to users. Is it possible to make the window as big as it needs to be and then not touch its size after that?

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

    Default Re: Need a Layout Manager that can change size of window

    Yes, it would be OK for me to make the window a single larger size and leave it, but I'm not sure how to do that.

Similar Threads

  1. [SOLVED] Layout Manager and Keyboard Panel
    By DOLZero in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 22nd, 2012, 12:19 PM
  2. Problem with layout manager
    By mDennis10 in forum AWT / Java Swing
    Replies: 1
    Last Post: September 4th, 2011, 07:47 PM
  3. Layout Manager
    By mDennis10 in forum AWT / Java Swing
    Replies: 4
    Last Post: September 3rd, 2011, 10:27 PM
  4. Layout manager
    By kurt-hardy in forum AWT / Java Swing
    Replies: 3
    Last Post: January 19th, 2011, 10:25 AM
  5. float based layout manager?
    By deepthought in forum AWT / Java Swing
    Replies: 1
    Last Post: January 1st, 2011, 10:11 PM

Tags for this Thread