import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Register
{
private JPanel panel;
private GridBagConstraints gc;
private JTextField userNumber;
private JTextField userNikeName;
private JTextField password;
private JTextField name;
private JTextField age;
public Register()
{
userNumber=new JTextField(15);
userNikeName=new JTextField(20);
password=new JTextField(20);
name=new JTextField(10);
age=new JTextField(8);
JFrame frame1=new JFrame("J-QQ用户注册");
frame1.show(true);
panel=new JPanel(new GridBagLayout());
gc=new GridBagConstraints();
gc.fill=GridBagConstraints.VERTICAL;
addComponent(new JLabel("用户号码:"),0,0,3,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(userNumber,0,1,4,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(new JLabel("用户昵称:"),2,0,3,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(userNikeName,2,1,4,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(new JLabel("用户口令:"),4,0,3,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(password,4,1,4,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(new JLabel("姓名:"),6,0,2,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(name,6,1,3,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(new JLabel("年龄:"),6,2,2,1);
gc.fill=GridBagConstraints.HORIZONTAL;
addComponent(age,6,3,2,1);
frame1.setSize(415,500);
frame1.add(panel);
}
public void addComponent(Component c,int row,int col,int nrow,int ncol)
{
gc.gridx = col;
gc.gridy = row;
gc.gridwidth = ncol;
gc.gridheight = nrow;
panel.add(c,gc);
}
public static void main(String[] args)
{
Register register=new Register();
}
}
[此贴子已经被作者于2007-8-26 0:30:06编辑过]