
code
JFrame jFrame = new JFrame();
jFrame.setBounds(200, 200, 1000, 800);
jFrame.setTitle("窗体");
try {
RunAbs.removeJavaIconImageSwing(jFrame);
} catch (Exception e) {
}
jFrame.setVisible(true);
Container container = jFrame.getContentPane();
container.setLayout(new GridBagLayout());//布局方式
int len = 9;
for (int i = 0; i < len; i++) {
GridBagConstraints gs1 = new GridBagConstraints();
gs1.gridx = i;
gs1.gridy = 0;
container.add(new JButton("组y " + i), gs1);
GridBagConstraints gs2 = new GridBagConstraints();
gs2.gridx = 0;
gs2.gridy = i;
container.add(new JButton("组x " + i), gs2);
}
GridBagConstraints gs1 = new GridBagConstraints();
gs1.gridx = 1;
gs1.gridy = 1;
gs1.gridwidth = 2;
gs1.gridheight = 2;
gs1.fill = GridBagConstraints.HORIZONTAL ;
container.add(new JButton("组1"), gs1);
GridBagConstraints gs3 = new GridBagConstraints();
gs3.gridx = 2;
gs3.gridy = 2;
gs3.gridwidth = 3;
gs3.gridheight = 3;
gs3.fill = GridBagConstraints.VERTICAL ;
container.add(new JButton("组3"), gs3);
GridBagConstraints gs4 = new GridBagConstraints();
gs4.gridx = 7;
gs4.gridy = 1;
gs4.gridwidth = 2;
gs4.gridheight = 2;
gs4.fill = GridBagConstraints.BOTH ;
container.add(new JButton("组4"), gs4);
组4没有上下填充啊
