frame.setLayout(new GridLayout(3,1));
This is your first mistake. The cells of a GridLayout
are all the same size, while you want the central part to be higher.
frame.add(topPanel,BorderLayout.NORTH);
....
frame.add(centerPanel,BorderLayout.CENTER);
This is the second one, you set frame to have a GridLayout
, so you shouldn't use BorderLayout
constraints.
The correct thing to do, in my opinion, is to remove the first line, and leave the frame with the default border layout.
As for your issue with the grid, it's due to the fact that you're not filling the grid. If you insert 4 controls in the grid, or initialize the grid with (1,2), you will get the expected outcome.
This is with centerPanel.setLayout(new GridLayout(1,2));
:
And this is with `
centerPanel.add(typeLabel);
centerPanel.add(vList);
centerPanel.add(new JLabel());
centerPanel.add(new JLabel());