package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
public class LoginFrame extends JFrame
{
private static final long serialVersionUID = 7305643042548754587L;
JButton btnLogin;
JButton btnCancel;
JTextField txtUsername;
JPasswordField txtPassword;
MyDB myDB=new MyDB();
public LoginFrame()
{
setSize(400,200);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
setTitle("登录");
JLabel lblUsername=new JLabel("账号:");
JLabel lblPassword=new JLabel("密码:");
txtUsername=new JTextField(30);
txtPassword=new JPasswordField(30);
JPanel panelUsername=new JPanel();
(lblUsername);
(txtUsername);
JPanel panelPassword=new JPanel();
(lblPassword);
(txtPassword);
btnLogin=new JButton("确定");
btnCancel=new JButton("重置");
JPanel btnPanel=new JPanel();
(btnLogin);
(btnCancel);
JPanel coutainer=new JPanel();
(panelUsername);
(panelPassword);
(btnPanel);
add(coutainer);
addListeners();
setVisible(true);
}
public void addListeners()
{
ActionListener btnLoginClick= new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Student student=new Student();
(());
int result= new LoginDao().select(()+"", ()+"");
if(result>0)
{
(null, "登录成功");
setVisible(false);
MainFrame mainFrame =new MainFrame();
(true);
}
else{
(null, "用户名或者密码错误");
}
}
};
(btnLoginClick);
}
}