代码拉取完成,页面将自动刷新
package sqltest;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SystemStudentPanel extends JPanel implements ActionListener {
private JLabel sno = null;
private JLabel password = null;
private JTextField getSno = null;
private JPasswordField getPassword = null;
private JButton loginButton = null;
public String inputSno;
String inputPassword;
Redis redis=null;
public SystemStudentPanel() {
sno = new JLabel("学号:");
getSno = new JTextField(null, 8);
password = new JLabel("登陆密码:");
getPassword = new JPasswordField(null, 8);
loginButton = new JButton("登录");
loginButton.addActionListener(this);
add(sno);
add(password);
add(getSno);
add(getPassword);
add(loginButton);
setVisible(true);
}
public boolean login(String sno, String password) {
Connector connector = new Connector();
if (password.equals(connector.getDBPassword(sno))) {
return true;
} else {
return false;
}
}
public void actionPerformed(ActionEvent e) {
redis=new Redis();
inputSno = getSno.getText();
inputPassword = new String(getPassword.getPassword());
redis.delSno();
if (login(inputSno, inputPassword)==true && e.getSource() == loginButton) {
redis.setRedis(inputSno,inputPassword);
redis.setSno(inputSno);
JOptionPane.showMessageDialog(this, "登陆成功!", "提示", JOptionPane.PLAIN_MESSAGE);
new StudentSelectFrame();
} else if(login(inputSno, inputPassword)==false && e.getSource() == loginButton) {
JOptionPane.showMessageDialog(this, "学号或登录密码输入错误!请重新输入!", "提示", JOptionPane.WARNING_MESSAGE);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。