import java.awt.*;
import javax.swing.*;
public class text extends JFrame{
public static void main(String[] args){
new text();
}
public text(){
super("邮件窗口");
Label receiveLabel=new Label("收件人");
Label ccLabel=new Label("抄送");
Label subjectLabel=new Label("主题");
Label accessoryLabel=new Label("附件");
TextField receiveField=new TextField();
TextField ccField=new TextField();
TextField subjectField=new TextField();
TextArea accessoryArea=new TextArea(1,40);
TextArea mailArea=new TextArea(8,40);
this.setLayout(new java.awt.GridBagLayout());
GridBagConstraints gridBag=new GridBagConstraints();
gridBag.fill=GridBagConstraints.HORIZONTAL;
gridBag.weightx=0;
gridBag.weighty=0;
receiveLabel.setFont(new Font("Alias",Font.BOLD,16));
this.add(receiveLabel,gridBag,0,0,1,1);
ccLabel.setFont(new Font("Alias",Font.BOLD,16));
this.add(ccLabel,gridBag,0,1,1,1);
subjectLabel.setFont(new Font("Alias",Font.BOLD,16));
this.add(subjectLabel,gridBag,0,2,1,1);
accessoryLabel.setFont(new Font("Alias",Font.BOLD,16));
this.add(accessoryLabel,gridBag,0,3,1,1);
gridBag.weightx=100;
gridBag.weighty=0;
this.add(receiveField,gridBag,1,0,1,1);
this.add(ccField,gridBag,1,1,2,1);
this.add(subjectField,gridBag,1,2,2,1);
accessoryArea.setEditable(false);
this.add(accessoryArea,gridBag,1,3,2,1);
gridBag.fill=GridBagConstraints.BOTH;
gridBag.weightx=100;
gridBag.weighty=100;
this.add(mailArea,gridBag,0,4,3,1);
this.setLocation(120,150);
this.setSize(300,300);
this.setDefaultCloseOperation(3);
this.setVisible(true);
}
private void add(Component c,GridBagConstraints gbc,int x,int y,int w,int h){
gbc.gridx=x;
gbc.gridy=y;
gbc.gridheight=h;
gbc.gridwidth=w;
add(c,gbc);
}
}
在这个程序中:
gridx,gridy,gridheight,gridwidth,weigthx,weigthy
如何理解,我已经看过帮助,但看不懂,希望各位详细解释。