package com.s197.viwe;
import java.awt.BorderLayout;
import java.awt.Dimension;
import com.s197.model.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import javax.swing.JLabel;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class RegisterFrame extends JFrame {
JLabel JLName = new JLabel();
JLabel JLPassWord = new JLabel();
JLabel JLPassWord1 = new JLabel();
ButtonGroup buttonGroup1 = new ButtonGroup();
ButtonGroup buttonGroup2 = new ButtonGroup();
JLabel Sex = new JLabel();
JLabel name = new JLabel();
JLabel JLType = new JLabel();
JLabel JLClass = new JLabel();
JButton JBT = new JButton();
JTextField txtName = new JTextField();
JPasswordField txtPassword = new JPasswordField();
JPasswordField txtPassword2 = new JPasswordField();
JTextField txtUserName = new JTextField();
JRadioButton rdiman = new JRadioButton();
JRadioButton rdiWoman = new JRadioButton();
JComboBox TypeBox = new JComboBox();
JRadioButton rdiTch = new JRadioButton();
JRadioButton rdiStu = new JRadioButton();
public RegisterFrame() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
this.setResizable(false);
setSize(new Dimension(400, 480));
setTitle("用户注册");
this.getContentPane().setLayout(null);
JLName.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
JLName.setForeground(Color.black);
JLName.setHorizontalAlignment(SwingConstants.CENTER);
JLName.setText("登陆名称:");
JLName.setBounds(new Rectangle(25, 23, 80, 26));
JLPassWord.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
JLPassWord.setHorizontalAlignment(SwingConstants.CENTER);
JLPassWord.setText("密 码:");
JLPassWord.setBounds(new Rectangle(27, 69, 73, 25));
JLPassWord1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
JLPassWord1.setHorizontalAlignment(SwingConstants.CENTER);
JLPassWord1.setText("确认密码:");
JLPassWord1.setBounds(new Rectangle(27, 127, 73, 30));
Sex.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
Sex.setHorizontalAlignment(SwingConstants.CENTER);
Sex.setText("性 别:");
Sex.setBounds(new Rectangle(25, 174, 66, 30));
name.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
name.setHorizontalAlignment(SwingConstants.CENTER);
name.setText("真实姓名:");
name.setBounds(new Rectangle(25, 225, 77, 23));
JLType.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
JLType.setHorizontalAlignment(SwingConstants.CENTER);
JLType.setText("用户身份:");
JLType.setBounds(new Rectangle(25, 278, 79, 30));
JLClass.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
JLClass.setHorizontalAlignment(SwingConstants.CENTER);
JLClass.setText("所在班级:");
JLClass.setBounds(new Rectangle(28, 332, 80, 28));
JBT.setBounds(new Rectangle(290, 397, 86, 34));
JBT.setFont(new java.awt.Font("新宋体", Font.PLAIN, 16));
JBT.setBorder(BorderFactory.createRaisedBevelBorder());
JBT.setText("提 交");
JBT.addActionListener(new RegisterFrame_JBT_actionAdapter(this));
txtName.setText("");
txtName.setBounds(new Rectangle(115, 24, 201, 25));
txtPassword.setText("");
txtPassword.setBounds(new Rectangle(115, 73, 200, 25));
txtPassword2.setText("");
txtPassword2.setBounds(new Rectangle(115, 130, 200, 25));
txtUserName.setText("");
txtUserName.setBounds(new Rectangle(115, 224, 200, 25));
rdiman.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
rdiman.setText("男");
rdiman.setBounds(new Rectangle(115, 174, 64, 30));
rdiWoman.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
rdiWoman.setText(" 女");
rdiWoman.setBounds(new Rectangle(229, 177, 58, 24));
TypeBox.setBounds(new Rectangle(115, 331, 143, 25));
TypeBox.addItem("-----请选择-----");
TypeBox.addItem("S197");
TypeBox.addItem("S198");
TypeBox.addItem("S199");
TypeBox.addItem("S200");
TypeBox.addItem("S201");
rdiTch.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
rdiTch.setText("教 师");
rdiTch.setBounds(new Rectangle(115, 280, 70, 25));
rdiStu.setFont(new java.awt.Font("新宋体", Font.PLAIN, 14));
rdiStu.setText("学 生");
rdiStu.setBounds(new Rectangle(229, 278, 64, 25));
this.getContentPane().add(JLName);
this.getContentPane().add(JBT);
this.getContentPane().add(txtPassword2);
this.getContentPane().add(txtUserName);
this.getContentPane().add(Sex);
this.getContentPane().add(name);
this.getContentPane().add(JLType);
this.getContentPane().add(txtPassword);
this.getContentPane().add(TypeBox);
this.getContentPane().add(rdiTch);
this.getContentPane().add(rdiStu);
this.getContentPane().add(JLPassWord);
this.getContentPane().add(JLPassWord1);
this.getContentPane().add(JLClass);
this.getContentPane().add(txtName);
this.getContentPane().add(rdiWoman);
this.getContentPane().add(rdiman);
buttonGroup1.add(rdiman);
buttonGroup1.add(rdiWoman);
buttonGroup2.add(rdiTch);
buttonGroup2.add(rdiStu);
}
public void JBT_actionPerformed(ActionEvent e) {
//取得用户输入的数据,封装到User中
String name=txtName.getText();
//进行表单验证
if(name.equals("")||name==null){
javax.swing.JOptionPane.showMessageDialog(this,"用户名不能为空!");
return;
}
//获得其他内容,并且验证
//获得用户性别
int sex;
if(rdiman.isSelected()){
sex=1;
}else{
sex=2;
}
//获得用户班机
if(TypeBox.getSelectedIndex()==0){
javax.swing.JOptionPane.showMessageDialog(this,"请选择班机!");
return;
}
String className=(String)TypeBox.getSelectedItem();
//获得的内容封装到JavaBean
User u=new User();
u.setUsername(name);
}
}
class RegisterFrame_JBT_actionAdapter implements ActionListener {
private RegisterFrame adaptee;
RegisterFrame_JBT_actionAdapter(RegisterFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.JBT_actionPerformed(e);
}
}