background image

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

dispose();

}

});

}

class b1 implements ActionListener {

public void actionPerformed(ActionEvent e) {

String s1 = f1.getText();
String s2 = f2.getText();

int flag = 1;
while (flag == 1) {

try {

if (s1.equals("") || s2.equals("")) {

throw new MyException("用户名或密码没有输入!");

}
if (s1.equals("3stone") && s2.equals("123456")) {

JOptionPane.showMessageDialog(denglu.this, "登录成功!");
flag = 0;
i = 1;

} else {

if (i < 3) {

JOptionPane.showMessageDialog(denglu.this,

"用户名或密码错误!请重新输入");

f1.setText("");
f2.setText("");
i++;
flag = 0;

} else {

JOptionPane.showMessageDialog(denglu.this,

"错误次数过多!将退出登录系统!");

dispose();
flag = 0;

}

}

} catch (MyException e1) {

JOptionPane.showMessageDialog(denglu.this, "用户名或密码没有输

入!");

flag = 0;

}

}