【检测】
JButton btn_1 = new JButton("\u68C0\u6D4B");
btn_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String username=textField_1.getText();
if(username.length()>18){
JOptionPane.showMessageDialog(null,"您输入的用户名不能超过18位");}
else{
select(username);
}
}
});
【注册】
JButton btn_2 = new JButton("\u6CE8\u518C");
btn_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String username=textField_1.getText();
String psd_1=newString(((JPasswordField) textField_2).getPassword());
String psd_2=newString(((JPasswordField) textField_3).getPassword());
if(psd_1.length()==0){JOptionPane.showMessageDialog(null,"您输入的密码不能为空");}
else{
if(psd_1.length()>16){JOptionPane.showMessageDialog(null,"您输入的密码不能超过16位");}
else{
if(psd_2.length()==0){
JOptionPane.showMessageDialog(null,"请再次输入您的密码");}
else{
if(!psd_1.equals(psd_2)){
JOptionPane.showMessageDialog(null,"两次密码不一致,请重新输入");}
else{
addRow(username,psd_1);}
}
}
【重输】
JButton btn_3 = new JButton("\u91CD\u8F93");
btn_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textField_1.setText("");
textField_2.setText("");
textField_3.setText("");
}
});