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

📄 denglu.java~12~

📁 车辆管理系统
💻 JAVA~12~
字号:
package carmanage;

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import DB.DbService;
import javax.swing.JComboBox;

public class DengLu extends JFrame {

    public DengLu() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(null);
        btnOk.setBounds(new Rectangle(46, 241, 101, 43));
        btnOk.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        btnOk.setText("登录");
        btnOk.addActionListener(new DengLu_btnOk_actionAdapter(this));
        btnCancle.setBounds(new Rectangle(253, 241, 93, 42));
        btnCancle.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        btnCancle.setText("返回");
        btnCancle.addActionListener(new DengLu_btnCancle_actionAdapter(this));
        jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jLabel1.setText("用户名:");
        jLabel1.setBounds(new Rectangle(41, 112, 96, 40));
        jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jLabel2.setText("密码:");
        jLabel2.setBounds(new Rectangle(65, 167, 83, 38));
        txtName.setBounds(new Rectangle(143, 115, 161, 31));
        jPasswordField1.setBounds(new Rectangle(143, 171, 159, 32));
        jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jLabel3.setText("登陆方式");
        jLabel3.setBounds(new Rectangle(26, 61, 84, 38));
        jComboBox1.setBounds(new Rectangle(144, 67, 161, 29));
        jComboBox1.addActionListener(new DengLu_jComboBox1_actionAdapter(this));
        this.getContentPane().add(btnOk);
        this.getContentPane().add(btnCancle);
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jLabel3);
        this.getContentPane().add(jPasswordField1);
        this.getContentPane().add(txtName);
        this.getContentPane().add(jComboBox1);
        this.setSize(400,400);
        this.setVisible(true);
        setTitle("用户登录");
    }
    String Fg[]={"管理员","审批员","调度员","申请人"};
    JComboBox jComboBox1 = new JComboBox(Fg);
    JButton btnOk = new JButton();
    JButton btnCancle = new JButton();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JTextField txtName = new JTextField();
    JPasswordField jPasswordField1 = new JPasswordField();
    JLabel jLabel3 = new JLabel();

    public void btnCancle_actionPerformed(ActionEvent e) {
    this.dispose();
    }

    public void btnOk_actionPerformed(ActionEvent e) {
                DbService dbservice=new DbService();
                String user = "" + this.txtName.getText();
                String password = new String(this.jPasswordField1.getPassword());
                String type =  (String)this.jComboBox1.getSelectedItem();
                if(user.length()!=0){
                String msg =dbservice.findUser(user,password,type);
             javax.swing.JOptionPane.showMessageDialog(this, msg);

             if(msg == "失败"){
                 txtName.setText("");
                 jPasswordField1.setText("");
             }
         }
         else{
             javax.swing.JOptionPane.showMessageDialog(this, "用户名不能为空!");
             //txtname.setText("");
             jPasswordField1.setText("");
         }
     }



    public void jComboBox1_actionPerformed(ActionEvent e) {

    }
}


class DengLu_jComboBox1_actionAdapter implements ActionListener {
    private DengLu adaptee;
    DengLu_jComboBox1_actionAdapter(DengLu adaptee) {
        this.adaptee = adaptee;
    }

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


class DengLu_btnOk_actionAdapter implements ActionListener {
    private DengLu adaptee;
    DengLu_btnOk_actionAdapter(DengLu adaptee) {
        this.adaptee = adaptee;
    }

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


class DengLu_btnCancle_actionAdapter implements ActionListener {
    private DengLu adaptee;
    DengLu_btnCancle_actionAdapter(DengLu adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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