importjavax.swing.border.EmptyBorder;
importjavax.swing.event.DocumentEvent;
importjavax.swing.event.DocumentListener;
importjavax.swing.text.Document;
importjava.awt.*;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.ResultSet;
importjava.sql.SQLException;
publicclassLoginextendsJFrame{
privateJPanelcontentPane;
privateJTextFieldjt_user;
privateJPasswordFieldjt_psw;
publicstaticJrame2jrame;
privatefinalJPanelpanel_3=newJPanel();
publicstaticvoidmain(String[]args){
EventQueue.invokeLater(newRunnable(){
publicvoidrun(){
try{
Loginframe=newLogin();
frame.setVisible(true);
}catch(Exceptione){
e.printStackTrace();
}
});
/**
*Createtheframe.
*/
publicLogin(){
setBackground(newColor(224,255,255));
setIconImage(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/img/线性图书(1).png")));
setTitle("网上书店管理系统");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,610,377);
contentPane=newJPanel();
contentPane.setBackground(SystemColor.menu);
contentPane.setBorder(newEmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);
JPanelpanel=newJPanel();
panel.setBackground(SystemColor.menu);
panel.setBounds(10,25,576,81);
contentPane.add(panel);
panel.setLayout(null);
JLabellblNewLabel=newJLabel("WelcometousetheSystem!");
lblNewLabel.setIcon(newImageIcon(Login.class.getResource("/img/welcome.png")));
lblNewLabel.setBounds(73,25,435,34);
lblNewLabel.setForeground(newColor(0,0,0));
lblNewLabel.setFont(newFont("宋体",Font.BOLD,29));
panel.add(lblNewLabel);
JPanelpanel_1=newJPanel();
panel_1.setBackground(SystemColor.menu);
panel_1.setBounds(10,116,576,60);
contentPane.add(panel_1);
panel_1.setLayout(null);
JLabellblNewLabel_1=newJLabel("账号:");
lblNewLabel_1.setBounds(96,5,98,32);
lblNewLabel_1.setIcon(newImageIcon(Login.class.getResource("/img/账号(1).png")));
lblNewLabel_1.setFont(newFont("宋体",Font.BOLD,20));
panel_1.add(lblNewLabel_1);
jt_user=newJTextField();
jt_user.setBounds(199,6,281,30);
jt_user.setFont(newFont("宋体",Font.BOLD,20));
panel_1.add(jt_user);
jt_user.setColumns(25);
JLabelmess1=newJLabel("");
mess1.setFont(newFont("宋体",Font.PLAIN,14));
mess1.setForeground(Color.RED);
mess1.setBounds(199,38,125,24);
panel_1.add(mess1);
JPanelpanel_1_1=newJPanel();
panel_1_1.setBackground(SystemColor.menu);
panel_1_1.setBounds(10,186,576,60);
contentPane.add(panel_1_1);
panel_1_1.setLayout(null);
JLabellblNewLabel_1_1=newJLabel("密码:");
lblNewLabel_1_1.setBounds(97,10,98,32);
lblNewLabel_1_1.setIcon(newImageIcon(Login.class.getResource("/img/密码(7).png")));
lblNewLabel_1_1.setFont(newFont("宋体",Font.BOLD,20));
panel_1_1.add(lblNewLabel_1_1);
jt_psw=newJPasswordField();
jt_psw.setBounds(201,5,280,32);
jt_psw.setFont(newFont("宋体",Font.BOLD,15));
jt_psw.setColumns(25);
panel_1_1.add(jt_psw);
JLabelmess2=newJLabel("");
mess2.setForeground(Color.RED);
mess2.setFont(newFont("宋体",Font.PLAIN,14));
mess2.setBounds(201,36,125,24);
panel_1_1.add(mess2);
JPanelpanel_2=newJPanel();
panel_2.setBackground(SystemColor.menu);
panel_2.setBounds(10,270,576,60);
contentPane.add(panel_2);
panel_2.setLayout(null);
JButtonjb_reset=newJButton("重置");
jb_reset.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
//重置输入框
jt_user.setText("");
jt_psw.setText("");
jb_reset.setIcon(newImageIcon(Login.class.getResource("/img/重置.png")));
jb_reset.setFont(newFont("宋体",Font.BOLD,17));
jb_reset.setBounds(113,10,97,23);
panel_2.add(jb_reset);
jb_login.addActionListener(newActionListener(){
//获取账号和密码
StringuserString=jt_user.getText();
char[]a=jt_psw.getPassword();
StringpswString=String.valueOf(a);
//查询是否匹配
Stringsql="select*frommanagerwhereuser=";
if(jt_user.getText().equals("")){
mess1.setText("请输入账号:");
}else{
ResultSetset=ConnectionManager.query(sql,newObject[]{userString});