I have been working on creating this specific layout using GridBagLayout:
Today somehow I managed to achieve it, however I have absolutely no idea how. I understand the grid mechanics, but it is specifically the setpreferredsize override and the weightx and weighty that confuse me.
For example, changing my code's weightx from 1 to 0 will produce this:
Returning to a weightx of 1 and changing my weighty to 0 instead will produce this:
Lastly, for each of my 3 panels, I use the following code when creating it:
JPanel connectionPanel = new JPanel() {
@Override
public Dimension getPreferredSize() {
return new Dimension(100, 100);
}
};
Changing the dimensions of one panel from 100 to, say 500 will produce this:
Similar happens when changing the height.
All I am trying to understand, is how the weightx, weighty, and setpreferredsize works.
When I call getpreferredsize of my panels, it returns a width and height of 0!
If I don't use the override to specifically change the preferredSize of even one of my panels, the output looks like this:
Can anyone please explain how these are related?
I've read the docs, but they are very vague. Researched for hours and still have no understanding.