Hi!

I have to make some modifications to a Swing application that was made many years ago and I can't seem to figure out why the content in one of the JPanel expands to take all available space...

The screen is made of, mostly, of 5 JPanels like this

123
45

Each of the JPanels have a BoxLayout.

JPanel 1, 2 and 3 get put together in a JPanel with a BorderLayout, the same thing happens to JPanel 4 and 5...

They later get all put in one big JPanel which has a BoxLayout.

My problem is with JPanel 2 which has both a its preferred size and maximum size set.

JPanel 1 and JPanel 3 have 4 rows, while JPanel 2 only has 3.

Something like

111
222
333
4 4

Even though that panel has a maximum size and preferred size set and a BoxLayout (which I thought I had read respects sizes?) the content of the panel get resized to fill the available space made by the additional row of the two neighboring JPanels.

Now JPanel 2 itself has a BoxLayout but each line in it has a BorderLayout.

Each line consists of a JLabel on the left and a JTextField or JComboBox on the right.

The JLabel doesn't have a size defined but the JTextField or JComboBox do...

Sometimes some of those JPanels have borders, horizontal struts or both...

I don't know how normal (or convoluted...) it is to have so many panels inside panels inside panels in them as before today I never had to change anything there or barely.

The only thing I know is that this is what I have to work with...

How can I address, with the minimal amount of change, this problem?

Thank you and have a nice day!

Nick