在JFrame里用网格包就提示找不到addComponent(javax.swing.JTextField,int,int,int,int)
但是该成Frame就没有问题了。是不是在JFrame里并不支持网格包呢?
public abc()
{
super("温度变换");
setDefaultCloseOperation(3);
con=getContentPane();
con.setLayout(gb);

con.addComponent(jf,0,0,4,2);
this.setSize(200,300);
this.setVisible(true);
}

public void addComponent(Component c,int row,int col,int nrow,int ncol)
{
gbc.gridx=row;
gbc.gridy=col;

gbc.gridwidth=nrow;
gbc.gridheight=ncol;

gbc.fill=GridBagConstraints.BOTH;

con.add(c);
}