建立一個數據庫userdb,該庫中有一個名為user的表,該表用於存放註冊使用者的資訊,user ( id char(18) not null primary key, psd char(16))。 完
【檢測】
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
else{
select(username);
}
}
});
【註冊】
JButton btn_2 = new JButton("\u6CE8\u518C");
btn_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String username
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("");
}
});