日期:2014-05-20 浏览次数:20753 次
boolean flag = false; public void text(){ String s2 = text2.getText(); String a2 = "\\w+@\\w+(\\.\\w+)+"; boolean flag2 = s2.matches(a2); String s4 = text4.getText(); String a4 = "[2]\\d{10}"; boolean flag4 = s4.matches(a4); String s5 = text5.getText(); String a5 = "\\w{6,10}"; boolean flag5 = s5.matches(a5); if(!flag2) JOptionPane.showMessageDialog(this,"您输入了非法字符","警告提示框", JOptionPane.WARNING_MESSAGE); else if(!flag4) JOptionPane.showMessageDialog(this,"学号错误!","警告提示框", JOptionPane.WARNING_MESSAGE); else if(!flag5) JOptionPane.showMessageDialog(this,"密码错误!","警告提示框", JOptionPane.WARNING_MESSAGE); else{ new login(); flag = true; } } public void myevent(){ addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ setVisible(false); } }); submit.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if(e.getSource()==submit){ text(); // zhuce(); String s1 = text1.getText(); String s2 = text2.getText(); String s3 = text3.getText(); String s4 = text4.getText(); String s5 = text5.getText(); try{ FileWriter fw = new FileWriter("1.txt",true); if(flag){ fw.write(s1+" "+s2+" "+s3+" "+s4+" "+s5+"\r\n"); fw.flush(); fw.close(); } } catch(IOException e1){} } } });