So it's a pretty simple problem, but I can't find a simple way to implement it. I basically have 3 instances of JPanel: north, south and center. Normally, if you play with window height, the center panel will be variable. What I would like, is to have the south panel height being variable instead of the center one.
Here is the code:
public class TestCode {
public static void main(String[] args) {
JFrame window = new JFrame("Test");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(300, 300);
JPanel panelUp = new JPanel();
JPanel panelCenter = new JPanel();
JPanel panelDown = new JPanel();
window.add(panelUp, BorderLayout.NORTH);
window.add(panelCenter, BorderLayout.CENTER);
window.add(panelDown, BorderLayout.SOUTH);
panelUp.setBackground(new Color(200, 240, 200));
panelCenter.setBackground(new Color(240, 200, 200));
panelDown.setBackground(new Color(200, 200, 240));
panelUp.setPreferredSize(new Dimension(panelUp.getWidth(), 50));
panelCenter.setPreferredSize(new Dimension(panelCenter.getWidth(), 100));
panelDown.setPreferredSize(new Dimension(panelDown.getWidth(), window.getHeight() - 150));
window.setVisible(true);
}
}