Java GridBagLayout位置应该在另一个位置?

Java GridBagLayout位置应该在另一个位置?,java,swing,layout-manager,gridbaglayout,Java,Swing,Layout Manager,Gridbaglayout,我有以下代码 GridBagConstraints c = new GridBagConstraints(); c.gridx=0; c.gridy=0; c.gridwidth=1; c.gridheight=1; c.fill = GridBagConstraints.BOTH; c.insets= new Insets(2,2,2,2); this.add(pdfUrl,c); c.gridx=1; c.weightx

我有以下代码

GridBagConstraints c = new GridBagConstraints();
    c.gridx=0;
    c.gridy=0;
    c.gridwidth=1;
    c.gridheight=1;
    c.fill = GridBagConstraints.BOTH;
    c.insets= new Insets(2,2,2,2);
    this.add(pdfUrl,c);
    c.gridx=1;
    c.weightx=0.1;
    c.gridwidth=4;
    this.add(pdfUrlin,c);
    c.gridx=0;
    c.gridwidth=1;
    c.gridy=1;
    c.weightx=0.0;
    this.add(pdfType);
此代码生成此

我不明白为什么PDF类型不在下面的行中。有人能帮我吗


提前感谢

添加pdfType时,您没有使用GridBagConstraints。不应该这样

this.add(pdfType);
而是

add(pdfType, c); // also no need for "this"

小错误,我想你的意思是:
this.add(pdfType,c)
而不是
this.add(pdfType)=)

天哪!真不敢相信。非常感谢!