Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:52:08+00:00 2026-06-11T06:52:08+00:00

It is possible to limit the cell size(height/width) in a GridBagLayout? I mean.. i

  • 0

It is possible to limit the cell size(height/width) in a GridBagLayout?

I mean.. i have a 2 rows that have same weightx = 0.5, but when i resize i don’t want first row to get higher than 300 pixels.

Also i don’t want it to not take any available space if it is smaller than 300. (setting weightx to 0).
It makes no sense to set maximum size for my component in the cell, because when i resize all available space is filled with the component(component is resized to fill the cell).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:52:10+00:00Added an answer on June 11, 2026 at 6:52 am

    To my knowledge it can’t be done with GridBagLayout. Luckily there are alternatives. MiGLayout works similarly to GridBagLayout but is more powerful and more expressive. It is also cell-based and will let you set the minimum, preferred and maximum sizes of cells and rows/columns of cells

    Though I recommend you work out your own solution as this one relies too heavily on row constraints for my liking and is based on a few assumptions about what you want, here’s an example:

    JPanel panel = new JPanel(new MigLayout("flowy, fillx, filly", "[fill, grow]", "[fill, 0:100:300][fill, 0:100:max(100%,300)]"));
    JPanel redPanel = new JPanel();
    redPanel.setBackground(Color.RED);
    JPanel bluePanel = new JPanel();
    bluePanel.setBackground(Color.BLUE);
    
    panel.add(redPanel);
    panel.add(bluePanel);
    
    JFrame frame = new JFrame();
    frame.add(panel);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to limit the size of attachment that can be send or
Say that I have a table with two rows, and a cell in each.
Is it possible to limit the number of rows that are updated using Hibernate/HQL?
Using guava 12 Collections2.permutations() , I'm wondering if it's possible to limit the size
Is it possible to set the stack limit in DevC++? Basically the same as
Is it possible to let MySQL LIMIT have an offset of the total number
Is it possible to limit the amount of times that setInterval will fire in
Is it possible to limit the set of characters that tesseract is looking for
Possible Duplicate: 2GB limit on file size when using fwrite in C? I realized
Is it possible to limit the number of properties that an attribute is applied

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.