简体   繁体   中英

How to make equally divided cells in Intellij Java GUI designer GridlayoutManager

I am new to IntelliJ java GUI designer and I found the default GridlayoutManager really confusing. Please check the picture attached.(This is my first question in SO, not enough reputation to insert image in post :{ ) GUI designer screenshot

I'd like to make area A and area B to be equal in width.

I've tried to adjust some of the properties such as "can grow" "want grow" "can shrink" but unfortunately none of them seems to change anything.

I tried adjust the green bars outside the panel but it does not allow me to do so...

Any tutorial on this designer or any idea on how to make them equally divided will be much appreciated.

GridLayout comes with 3 different Constructors:

GridLayout() //the default one
GridLayout(int rows, int col) // defining no of rows and no of columns.
GridLayout(int rows, int col, int hgap, int vgap) // defining no of rows and columns with certain gap.

Third constructor takes care of the width of the column by adjusting itself according to the dimensions of the component placed in it. Reference: Grid Layout. According to your requirement, I would suggest you to go with BoxLayout. It will give equal size to both of your columns.

Not really a complete answer. But after playing around with this stuff for days, and there being a lack of documentation, here is a word of advice to anyone:

IntelliJ has its own lay-out manager called GridLayoutManager, which is the default option. GridLayoutManager tries to set the size of your components based on the preferred, minimum and maximum height/width of the component. The lay-out manager also takes other factors into account such as the size of the container, the horizontal/vertical align settings, the horizontal/vertical size policy settings etc. In different situations the manager will prioritise one setting over the other. You will have to take all these settings into account, if the GridLayoutManager is not listening.

Good luck trying to figure out in what order settings are prioritised. You're on your own ;) It's a frustrating journey to even get a basic lay-out going, especially if you've designed C# forms or websites before...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM