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

📄 login.java

📁 一个个人信息管理系统
💻 JAVA
字号:
package soft1;

import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Font;
import javax.swing.BorderFactory;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Rectangle;
import com.borland.dx.sql.dataset.Load;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import com.borland.dbswing.JdbCheckBox;
import com.borland.dbswing.JdbTable;
import com.borland.dx.dataset.Column;
import java.awt.Color;
import javax.swing.border.TitledBorder;
import Soft1.*;
import soft1Method.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusAdapter;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.awt.Dimension;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Login extends JFrame {
    BorderLayout borderLayout1 = new BorderLayout();
    JLabel jLabel1 = new JLabel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    public  JComboBox jComboBox1 = new JComboBox();
    //private QueryDataSet queryDataSet1 = new QueryDataSet();
    JButton jButton3 = new JButton();
    TitledBorder titledBorder1 = new TitledBorder("");
    TitledBorder titledBorder2 = new TitledBorder("");
    Icon img1= new   ImageIcon("src/Pic/Login.png");
    JPasswordField jPasswordField1 = new JPasswordField();
   Dataset2 dataset2=new Dataset2();
   MiddleLoc middleloc=new MiddleLoc();
   GetValue getvalue=new GetValue();
   Ricgz2 ricgz2=new Ricgz2();
   public String PostValue;
    XYLayout xYLayout1 = new XYLayout();
    JLabel jLabel2 = new JLabel();
    BG jPanel1 = new BG();
    XYLayout xYLayout2 = new XYLayout();
    TitledBorder titledBorder3 = new TitledBorder("");
    TitledBorder titledBorder4 = new TitledBorder("");
    public Login() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
    class BG extends JPanel {

            public void paintComponent(Graphics g) {
                    super.paintComponent(g);
                    Toolkit toolImg = this.getToolkit();
                    Image img = toolImg.getImage("src/Pic/3.PNG");
                    g.drawImage(img,0,0,this.getSize().width,this.getSize().height,this);
            }
            }

    private void jbInit() throws Exception {
        this.getContentPane().setBackground(new Color(205, 205, 255));
        //getContentPane().setLayout(borderLayout1);
        setSize(new Dimension(363, 316)); //this.setUndecorated(true);
        this.setTitle("登录");
        this.getContentPane().setLayout(null);
        setResizable(false);
        jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
        jLabel1.setBorder(null);
        jLabel1.setText("用户名:");
        jButton1.setBorder(null);
        jButton1.setIcon(null);
        jButton1.setText("确认");
        jButton1.addActionListener(new Login_jButton1_actionAdapter(this));
        jButton2.setBorder(null);
        jButton2.setText("重置");
        jButton2.addActionListener(new Login_jButton2_actionAdapter(this));
        jComboBox1.addFocusListener(new Login_jComboBox1_focusAdapter(this));
        jButton3.setText("新建帐号");
        jButton3.setOpaque(false);
        jButton3.setBorderPainted(false);
        jButton3.setContentAreaFilled(false);
        jButton3.addActionListener(new Login_jButton3_actionAdapter(this));
        jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
        jLabel2.setText("密码:");
        jPanel1.setBounds(new Rectangle(1, 1, 362, 295));
        jPanel1.setLayout(xYLayout2);
        this.getContentPane().add(jPanel1);
        jPanel1.add(jLabel2, new XYConstraints(57, 83, 58, 29));
        jPanel1.add(jLabel1, new XYConstraints(57, 40, 58, 29));
        jPanel1.add(jButton3, new XYConstraints(271, 40, -1, 31));
        jPanel1.add(jComboBox1, new XYConstraints(118, 40, 155, 31));
        jPanel1.add(jPasswordField1, new XYConstraints(118, 83, 155, 29));
        jPanel1.add(jButton1, new XYConstraints(74, 139, 69, 29));
        jPanel1.add(jButton2, new XYConstraints(194, 138, 69, 29));
    }
         public static void main(String[] args) {
        Login login = new Login();
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        jComboBox1.setSelectedIndex(0);
        jPasswordField1.setText("");
    }

    public void jComboBox1_actionPerformed(ActionEvent e) {

   }

    public void jButton1_actionPerformed(ActionEvent e) throws
            HeadlessException, ClassNotFoundException, SQLException {
     String s="SELECT * from User where Name ='"+jComboBox1.getSelectedItem()+"'and Password = '"+jPasswordField1.getText()+"'";
    //System.out.println(dataset2.Rs(s).next());
    //System.out.println(jComboBox1.getSelectedItem());
    //System.out.println(jPasswordField1.getPassword());System.out.println(s);
    if(dataset2.Rs(s).next())
    {  MainFrame frame1 = new MainFrame();
        PostValue=(String) jComboBox1.getSelectedItem();
        frame1.jLabel2.setText("欢迎您回来,"+PostValue);
        ricgz2.UserName2=PostValue;
        getvalue.SetValue(PostValue);
        System.out.print(getvalue.Getvalue());
        middleloc.setLocation1(frame1);
        this.setVisible(false);

     }else{
           //queryDataSet1.close();
           JOptionPane.showMessageDialog(this,"您输入的口令不正确!请重新输入!","提示",JOptionPane.ERROR_MESSAGE);
            return;
   }
   }



    public void jButton3_actionPerformed(ActionEvent e) {
     Xinjyh xjyh=new Xinjyh();
     middleloc.setLocation2(xjyh);


    }



class Login_jButton3_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_jButton3_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


    class Login_jButton1_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_jButton1_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        try {
            adaptee.jButton1_actionPerformed(e);
        } catch (SQLException ex) {
        } catch (ClassNotFoundException ex) {
        } catch (HeadlessException ex) {
        }
    }
}


/*class Login_jComboBox1_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_jComboBox1_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jComboBox1_actionPerformed(e);
    }
}*/


    public void jComboBox1_focusGained(FocusEvent e) {
        try{
      jComboBox1.setSelectedItem(null);
      jComboBox1.removeAllItems();
      String sqlQuery="select Name from User";
      Dataset2 dataset2=new Dataset2();
      jComboBox1.addItem("");
      ResultSet rs2=dataset2.Rs(sqlQuery);
      //System.out.print(dataset2.resultset(sqlQuery));
      while (rs2.next()) {
       jComboBox1.addItem(rs2.getString(1));
      }

    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }




    class Login_jButton2_actionAdapter implements ActionListener {
    private Login adaptee;
    Login_jButton2_actionAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}}


class Login_jComboBox1_focusAdapter extends FocusAdapter {
    private Login adaptee;
    Login_jComboBox1_focusAdapter(Login adaptee) {
        this.adaptee = adaptee;
    }

    public void focusGained(FocusEvent e) {
        adaptee.jComboBox1_focusGained(e);
    }
}

⌨️ 快捷键说明

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