注册界面

//MyFrame.java

import javax.swing.*;



public class MyFrame extends JFrame{
private JPanel contentPane;
private JLabel lab1,lab2,lab3,lab4,lab5,lab6,lab7,lab8;
private JTextField tf1,tf2;
private JPasswordField pwf1,pwf2;
private JTextArea ta;
private JCheckBox yes;
private JRadioButton rbtMale;
private JRadioButton rbtFemale;
private ButtonGroup grp;
private JComboBox cmbType;
public MyFrame(String s){
super(s);
setSize(320,400);
setLocationRelativeTo(null);
contentPane=new JPanel();
setContentPane(contentPane);
lab1=new JLabel("用户名:");
tf1=new JTextField(20);
lab2=new JLabel("密码:");
pwf1=new JPasswordField(20);
pwf1.setEchoChar('*');
lab3=new JLabel("确认密码:");
pwf2=new JPasswordField(20);
pwf2.setEchoChar('*');
lab4=new JLabel("个人简介:");
ta=new JTextArea(10,20);
lab5=new JLabel("性别:");
rbtMale=new JRadioButton("男");
rbtFemale=new JRadioButton("女");
grp=new ButtonGroup();
grp.add(rbtMale);
grp.add(rbtFemale);
lab6=new JLabel("证件类型:");
String type[]={"身份证","护照","学生证","驾驶证","军官证","其他"};
cmbType=new JComboBox(type);
lab7=new JLabel("证件号码:");
tf2=new JTextField(20);
lab8=new JLabel("同意服务条款:");
yes=new JCheckBox("我已经看过并同意使用协议");
contentPane.add(lab1);
contentPane.add(tf1);
contentPane.add(lab2);
contentPane.add(pwf1);
contentPane.add(lab3);
contentPane.add(pwf2);
contentPane.add(lab4);
contentPane.add(ta);
contentPane.add(lab5);
contentPane.add(rbtMale);
contentPane.add(rbtFemale);
contentPane.add(lab6);
contentPane.add(cmbType);
contentPane.add(lab7);
contentPane.add(tf2);
contentPane.add(lab8);
contentPane.add(yes);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}



}

//Frame.java

public class Frame {


public static void main(String[] args) {
// TODO Auto-generated method stub
    MyFrame frm=new MyFrame("注册界面");
}


}

你可能感兴趣的:(Swing)