我有这种格式的代码,但是 jpanels 没有听我设置的大小。当我运行代码时,所有三个面板的大小都相同。有没有办法调整它们?
JPanel mainpanel = new JPanel(mainPanel,BoxLayout.Y_AXIS);
JPanel tablepanel1 = new JPanel();
tablepanel1.setSize(900,400);
JPanel selectionpanel = new JPanel(new GridBagLayout());
selectionpanel.setSize(900,100);
JPanel tablepanel2 = new JPanel();
tablepanel2.setSize(900,400);
mainpanel.add(tablepanel1);
mainpanel.add(selectionpanel);
mainpanel.add(tablepanel2);
frame.add(mainpanel);
frame.setSize(900,900);