学生登陆页面java代码 学生登陆页面java代码怎么写( 七 )


passwordField.setBounds(150, 130, 148, 24);
contentPane.add(passwordField);
JButton login = new JButton("登录");
login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String username = textField.getText();
String password = passwordField.getText();
if("".equals(username)||username.trim()==null)
{
JOptionPane.showMessageDialog(null,"用户名不能为空学生登陆页面java代码!");
return;
}
if("".equals(password)||password.trim()==null)
{
JOptionPane.showMessageDialog(null,"密码不能为空学生登陆页面java代码!");
return;
}
Connection con= null;
User user = new User(username,password);
try {
con=dbUtil.getConnection();
User currentUser = userDao.login(user);
if(currentUser!=null)
{
dispose();
new MainFrame().setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null,"用户名或密码错误!");
}
} catch (Exception e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(null,"登陆失败!");
}finally{
try {
dbUtil.close(con);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
});
login.setBounds(82, 195, 113, 27);
contentPane.add(login);
JButton reset = new JButton("重置");
reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textField.setText("");
passwordField.setText("");
}
});
reset.setBounds(225, 195, 113, 27);
contentPane.add(reset);
}
public static void main(String[] args){
LogFrm frm = new LogFrm();
}
}
学生登陆页面java代码的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于学生登陆页面java代码怎么写、学生登陆页面java代码的信息别忘了在本站进行查找喔 。

推荐阅读