How to set center component on a fixed position in Java using GridLayout? -


I have this gridout in java.

There are 3 columns in left and right columns have an image and center column has data.

Since I have used so much to not use layout managers, I need to ask it here.

How can I set a variable width to the left and right column and center layout with a fixed so that the left and right columns will crop but the center column will remain intact and at the center of the screen?

And is it even possible with the grid layout?

A grid layout is very harsh for your application: you do it to others Can not tell for the treatment of certain rows or columns apart. You should probably have a look at GridBagLayout . There you can use the weight settings to distribute extra space in image parts, they fill the additional assigned space, and the central part of its preferred size. If the desired size is not of the size you want, you may need to wrap that component into some component for which you can set the preferred size.

Comments