/**
*
* 定义注册监听类
*
*/
public class RegistBtnActionListener implements ActionListener {
String userName = userNameJtf.getText(); String password = passwordJtf.getText(); String surePassword = surePasswordJtf.getText(); String email = emailJtf.getText(); public void actionPerformed(ActionEvent e){
if(userName.equals("")|password.equals("")|surePassword.equals("")|email.equals("")){
//判断是否没有填写完整
JOptionPane.showMessageDialog(null, "请将空白处填写完整", "提示信息", 2);
}else if (!password.equals(surePassword)){
JOptionPane.showMessageDialog(null, "对不起,前后密码不一致!","提示信息",JOptionPane.ERROR_MESSAGE);
passwordJtf.setText("");
surePasswordJtf.setText("");
return;
} else if (!email
.matches("^([a-z0-9A-Z]+[-1\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$")) {
JOptionPane.showMessageDialog(null, "对不起,你的邮箱格式不合法!","提示信息",JOptionPane.ERROR_MESSAGE);
emailJtf.setText("");
return;
} else {
JFrameRegist jr=new JFrameRegist();
jr.registConnect("E:\\musicPlatform");
JOptionPane.showMessageDialog(null, "注册成功!","提示信息",1);
}
}
}
*
* 定义注册监听类
*
*/
public class RegistBtnActionListener implements ActionListener {
String userName = userNameJtf.getText(); String password = passwordJtf.getText(); String surePassword = surePasswordJtf.getText(); String email = emailJtf.getText(); public void actionPerformed(ActionEvent e){
if(userName.equals("")|password.equals("")|surePassword.equals("")|email.equals("")){
//判断是否没有填写完整
JOptionPane.showMessageDialog(null, "请将空白处填写完整", "提示信息", 2);
}else if (!password.equals(surePassword)){
JOptionPane.showMessageDialog(null, "对不起,前后密码不一致!","提示信息",JOptionPane.ERROR_MESSAGE);
passwordJtf.setText("");
surePasswordJtf.setText("");
return;
} else if (!email
.matches("^([a-z0-9A-Z]+[-1\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$")) {
JOptionPane.showMessageDialog(null, "对不起,你的邮箱格式不合法!","提示信息",JOptionPane.ERROR_MESSAGE);
emailJtf.setText("");
return;
} else {
JFrameRegist jr=new JFrameRegist();
jr.registConnect("E:\\musicPlatform");
JOptionPane.showMessageDialog(null, "注册成功!","提示信息",1);
}
}
}
/**
*
* 定义注册监听类
*
*/
public class RegistBtnActionListener implements ActionListener {
String userName = userNameJtf.getText(); String password = passwordJtf.getText(); String surePassword = surePasswordJtf.getText(); String email = emailJtf.getText(); public void actionPerformed(ActionEvent e){
if(userName.equals("")||password.equals("")||surePassword.equals("")||email.equals("")){
//判断是否没有填写完整
JOptionPane.showMessageDialog(null, "请将空白处填写完整", "提示信息", 2);
}else if (!password.equals(surePassword)){
JOptionPane.showMessageDialog(null, "对不起,前后密码不一致!","提示信息",JOptionPane.ERROR_MESSAGE);
passwordJtf.setText("");
surePasswordJtf.setText("");
return;
} else if (!email
.matches("^([a-z0-9A-Z]+[-1\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$")) {
JOptionPane.showMessageDialog(null, "对不起,你的邮箱格式不合法!","提示信息",JOptionPane.ERROR_MESSAGE);
emailJtf.setText("");
return;
} else {
JFrameRegist jr=new JFrameRegist();
jr.registConnect("E:\\musicPlatform");
JOptionPane.showMessageDialog(null, "注册成功!","提示信息",1);
}
}
}
是因为“|”是非短路的吧,它会认认真真的检查每一个表达式
public static void main(String[] args) {
if(1==1){
System.out.println("1==1");
}else if(2==2){
System.out.println("2==2");
}else if(3==3){
System.out.println("3==3");
}
}
public class RegistBtnActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e){
if(userNameJtf.getText().equals("")||passwordJtf.getText().equals("")||surePasswordJtf.getText().equals("")||emailJtf.getText().equals("")){
//判断是否没有填写完整
JOptionPane.showMessageDialog(null, "请将空白处填写完整", "提示信息", 2);
}else if(!passwordJtf.getText().equals(surePasswordJtf.getText())){
//判断两次密码是否一致
JOptionPane.showMessageDialog(null, "对不起,密码填写的不一致,请重新填写", "提示信息", JOptionPane.ERROR_MESSAGE);
passwordJtf.setText("");
surePasswordJtf.setText("");
return;
}else if(!emailJtf.getText().matches("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")){
//判断邮件格式是否正确
JOptionPane.showMessageDialog(null, "对不起,您输入的邮件格式非法,请重新编写", "信息提示", JOptionPane.ERROR_MESSAGE);
emailJtf.setText("");
return;
}else{
//将信息写入文件
//this.registconnent();
JOptionPane.showMessageDialog(null, "恭喜您注册成功,点击返回进行登录!", "信息提示", 1);
}
}
}