I have been experimenting with layouts (border, flow, grid), but I still don't know how to get the result from my task.
My task is to organize components in a way shown in the attached picture. (calc.jpg) To be precise, while resizing a window horizontally components mustn't change their width, and space between all of the components has to be equal.
I tried to use FlowLayout. Size of my components doesn't change while resizing, but they are located in a centre. While resizing window, space between them is constant whereas a space on the left and on the right is getting bigger.
I tried to use BorderLayout. I located one component at west, another one at east, but the one at the centre filled the whole free space, eliminating any spaces. While resizing window a component in a centre was growing.
I tried to use GridLayout with a constant space between components. While resizing space between them is constant, but the components are getting bigger.
Summing up. I would like to get a layout in which one component is at the left side, another one at the right side, the other components are between them, components don't change their size while resizing window and space between each component is the same and increases while resizing window.
Thanks in advance.
You will need to use a combination of layouts by nesting JPanels, each one using its own layout. The button grids would be placed in a JPanel that uses GridLayout, and you'd likely need 4 JPanels for this, one for each cluster of JButtons. Then you could place these JPanels into a larger JPanel that uses BoxLayout oriented BoxLayout.PAGE_AXIS.
The key to figuring this out is to experiment with different variations.
Originally Posted by Fubarable
That's what I was looking for.
Thanks a lot!
You're welcome, but note that my suggestions were just that -- suggestions. There are many other and perhaps better ways to lay this out. Regardless again the key is to experiment.
Originally Posted by miller.bartek