我有一個主框架和3個面板。我想將這3個面板添加到主框架中。但是,其中只有2個被添加。第三個不是。我無法弄清楚爲什麼。有人可以幫忙嗎?面板不添加到主框架
setLayout(new GridBagLayout());
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridwidth=GridBagConstraints.REMAINDER;
gbc.gridheight=GridBagConstraints.RELATIVE;
gbc.anchor=GridBagConstraints.NORTHWEST;
gbc.fill=GridBagConstraints.BOTH;
gbc.weightx=gbc.weighty=1;
add(topPanel1, gbc);
add(bottomPanel1, gbc);
gbc.gridheight=GridBagConstraints.REMAINDER;
add(buttonsPanel, gbc);
上面的代碼是一個框架的構造函數。