小白提问:网格组布局的容器添加组件,为什么组件一直居中

public Test() {
setBounds(460, 100,1000, 800);
setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c=getContentPane();//获取窗体容器
    GridBagLayout gridbag=new GridBagLayout();//创建网格组布局
    c.setLayout(gridbag);//给容器设置网格组布局

    GridBagConstraints gbc=new GridBagConstraints();//创建组件约束对象
    gbc.gridx=0;
    gbc.gridy=0;
    gbc.gridwidth=5;
    gbc.gridheight=6;
    JLabel lable=new JLabel();
    lable.setText("标签");
    c.add(lable, gbc);

    setVisible(true);
}



运行后标签组件为什么是居中,而不是在左上角

https://www.cnblogs.com/kungfupanda/p/7220217.html