⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkid.java

📁 基于UML的书店采购管理系统设计主要是供书店管理员使用。系统提供了管理员登陆
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package book_booking;import javax.swing.JFrame;import java.awt.*;import javax.swing.*;import java.awt.event.*;//import javax.swing.border.*;import java.sql.*;/** * * @author Administrator */public class CheckID extends JFrame implements ActionListener{    private SqlBean sqlBean = new SqlBean();     JTextField usernameField;     JPasswordField passwordField;     JButton jbOK,jbCancel;        public CheckID()    {       usernameField=new JTextField(10);       passwordField=new JPasswordField(10);       jbOK=new JButton("确定",new ImageIcon("D:/book_booking/image/14.jpg"));       jbCancel=new JButton("取消",new ImageIcon("D:/book_booking/image/56.jpg"));       jbOK.addActionListener(this);       jbCancel.addActionListener(this);       Box box1=Box.createHorizontalBox();       box1.add(new JLabel("输入用户名:",new ImageIcon("D:/book_booking/image/47.jpg"),JLabel.CENTER));       box1.add(usernameField);              Box box2=Box.createHorizontalBox();       box2.add(new JLabel("输入密码:",new ImageIcon("D:/book_booking/image/17.jpg"),JLabel.CENTER));       box2.add(passwordField);              Box boxH=Box.createVerticalBox();       boxH.add(box1);       boxH.add(box2);       boxH.add(Box.createVerticalGlue());              JPanel pCenter=new JPanel();       pCenter.add(boxH);       setLayout(new BorderLayout());       add(pCenter,BorderLayout.CENTER);       JPanel pSouth=new JPanel();       pSouth.add(jbOK);       pSouth.add(jbCancel);       add(pSouth,BorderLayout.SOUTH);       addWindowListener(new WindowAdapter()		                 { public void windowClosing(WindowEvent e)		                     {		                     	System.exit(0);		                     }		                 });         setVisible(true);//                  setBounds(500,400,600,300);       validate();                        }    public void actionPerformed(ActionEvent e)     {        String username = usernameField.getText().trim();        String password = new String(passwordField.getPassword()).trim();        try        {            if (e.getSource() == jbOK)              {                if(username.equals(""))                   {                         JOptionPane.showMessageDialog(this,"用户名不能为空!","错误",JOptionPane.ERROR_MESSAGE);                         return;                   }                  String sqlStr="select * from login where user_name="+"'"+username+"'"+" and psw="+"'"+password+"'";                  ResultSet result=sqlBean.executeQuery(sqlStr);                  if(result.next())                  {                                       sqlBean.CloseDataBase();                        this.setVisible(false);                        this.dispose();                        Interface manager = new Interface();                        manager.setSize(650,600);                                              }                    else                        {                        JOptionPane.showMessageDialog(this,"对不起,用户名或密码不正确!","警告",JOptionPane.WARNING_MESSAGE);                                }                             }            else if (e.getSource() == jbCancel)	      {		this.setVisible(false);//		this.dispose();			      }        }        catch(Exception ex)	{		System.err.println(ex);	}    }     public static void main(String[] args)     {        CheckID frame = new CheckID();        frame.setSize(300,200);         frame.setVisible(true);    }       }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -