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

📄 sloginmenu.java

📁 管理系统
💻 JAVA
字号:
package com.aptech.cdjj.sex.gui;

/**
 * 标题: 登陆界面层
 * 小组:SEX
 * 时间:2007.8.31
 * 版本:1.0
 * 类名:SLoginMenu
 * 提示各组件命名规则以-后为前缀:JPanel--pnl,JScrollPane--scp,JTextArea--txa,JTextFileld--txt,JLabel--lbl,
 *                            JButton--btn,JCheckBox--chk,JComBox--cbo
 * 本类主要实现:通过连接数据库,核对输入用户帐号,密码。
 * 细节:界面层需导入javax.swing.*;包
 * 1:判断用户帐号,密码框是否为空,并重新获得焦点------文本框名:userName
 * 2:如果输入帐号既密码正确,给出提示(要求弹出消息框)-----密码框:userPwd
 * 3:判断登陆人员的等级情况(即属于哪一部门) ----下来菜单:cbodept
 * 4:以上判断都只需调用事务层SLonginAction类的处理方法boolean isLogin(String name,String pwd)
 */
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import java.awt.SystemColor;
import javax.swing.BorderFactory;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import com.aptech.cdjj.sex.database.SDBManager;
import java.util.*;
import com.aptech.cdjj.sex.database.SDBManager;
import java.awt.Font;

public class SLoginMenu extends JFrame {
    SLoginMenu(){
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        this.setUndecorated(true);
        this.setResizable(false);
        this.setSize(350,300);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = this.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        this.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);

        this.setVisible(true);
    }

    public static void main(String[] args) {
        SLoginMenu sloginmenu = new SLoginMenu();
    }

    private void jbInit() throws Exception {
        jLabel1.setText("登陆帐号:");
        jLabel1.setBounds(new Rectangle(18, 83, 66, 27));
        jLabel2.setText("登陆密码:");
        jLabel2.setBounds(new Rectangle(18, 116, 66, 27));
        jComboBox1.setBounds(new Rectangle(87, 153, 111, 22));
        jLabel3.setText("登陆级别:");
        jLabel3.setBounds(new Rectangle(18, 148, 66, 27));
        jPasswordField1.setBounds(new Rectangle(87, 119, 111, 24));
        jButton1.setBackground(Color.gray);
        jButton1.setBounds(new Rectangle(47, 219, 84, 24));
        jButton1.setBorder(BorderFactory.createEtchedBorder());
        jButton1.setText("确定");
        jButton1.addActionListener(new SLoginMenu_jButton1_actionAdapter(this));
        jButton2.setBackground(Color.gray);
        jButton2.setBounds(new Rectangle(130, 219, 84, 24));
        jButton2.setBorder(BorderFactory.createEtchedBorder());
        jButton2.setText("取消");
        jButton2.addActionListener(new SLoginMenu_jButton2_actionAdapter(this));
        jButton2.setHorizontalTextPosition(jButton2.RIGHT);
        ImageIcon image=new ImageIcon("/Jewelry/logo/jew_"+num+".jpg");
        jLabel11.setIcon(image);
        jPanel1.addMouseListener(new SLoginMenu_jPanel1_mouseAdapter(this));
        jLabel5.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 40));
        jLabel5.setForeground(Color.cyan);
        jLabel5.setText("S");
        jLabel5.setBounds(new Rectangle(29, 10, 23, 47));
        jLabel6.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 40));
        jLabel6.setForeground(Color.green);
        jLabel6.setText("E");
        jLabel6.setBounds(new Rectangle(66, 15, 27, 51));
        jLabel7.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 40));
        jLabel7.setForeground(Color.yellow);
        jLabel7.setText("X");
        jLabel7.setBounds(new Rectangle(104, 11, 27, 51));
        jLabel8.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 32));
        jLabel8.setForeground(Color.magenta);
        jLabel8.setText("小");
        jLabel8.setBounds(new Rectangle(144, 21, 32, 48));
        jLabel9.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 32));
        jLabel9.setForeground(Color.darkGray);
        jLabel9.setText("组");
        jLabel9.setBounds(new Rectangle(257, 7, 38, 51));
        jLabel10.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 32));
        jLabel10.setForeground(SystemColor.desktop);
        jLabel10.setText("制");
        jLabel10.setBounds(new Rectangle(177, 3, 38, 51));
        jLabel11.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 32));
        jLabel11.setForeground(Color.green);
        jLabel11.setBounds(new Rectangle(186, 18, 38, 51));
        jLabel11.setBounds(new Rectangle(1, 0, 398, 303));
        jLabel4.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 28));
        jLabel4.setText("做");
        jLabel4.setBounds(new Rectangle(218, 18, 35, 42));
        jLabel12.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 18));
        jLabel12.setForeground(SystemColor.desktop);
        jLabel12.setText("Jewelry珠宝管理系统");
        jLabel12.setBounds(new Rectangle(150, 255, 189, 36));
        this.getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
        jPanel1.add(jButton1);
        jPanel1.add(jButton2);
        jPanel1.add(jTextField1);
        jPanel1.add(jPasswordField1);
        jPanel1.add(jComboBox1);
        jPanel1.add(jLabel1);
        jPanel1.add(jLabel2);
        jPanel1.add(jLabel3);
        jPanel1.add(jLabel5);
        jPanel1.add(jLabel6);
        jPanel1.add(jLabel7);
        jPanel1.add(jLabel11);
        jPanel1.add(jLabel4);
        jPanel1.add(jLabel9);
        jPanel1.add(jLabel8);
        jPanel1.add(jLabel10);
        jPanel1.add(jLabel12);
        jPanel1.add(jLabel11);
        jTextField1.setBounds(new Rectangle(87, 85, 111, 25));
        jPanel1.setLayout(null);
        jComboBox1.setModel(new DefaultComboBoxModel(SDBManager.getOne("select steps from step")));
    }
    public static String name = "";
    public static String step = "";
    JPanel jPanel1 = new JPanel();
    JTextField jTextField1 = new JTextField();
    JPasswordField jPasswordField1 = new JPasswordField();
    JComboBox jComboBox1 = new JComboBox();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    int num = (int)Math.round(Math.random()*8);
    JButton jButton1 = new JButton(new ImageIcon("/Jewelry/pic/USER.GIF"));
    JButton jButton2 = new JButton(new ImageIcon("/Jewelry/pic/DEPT.GIF"));
    int count = 0;//计算登陆次数

    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JLabel jLabel9 = new JLabel();
    JLabel jLabel10 = new JLabel();
    JLabel jLabel11 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel12 = new JLabel();

    public void jButton1_actionPerformed(ActionEvent e) { //确认按纽事件
        name = jTextField1.getText();
        step = jComboBox1.getSelectedItem().toString();
        String step = jComboBox1.getSelectedItem().toString();
        String pwd = new String(jPasswordField1.getPassword());
        SGetDate sd = new SGetDate();
        if(name.length() == 0){
            jTextField1.requestFocus();
            return;
        }
        if(pwd.length() == 0){
            jPasswordField1.requestFocus();
            return;
        }
        String sql = "select uname from users where uname = '"+name+"'";
        String sql2 = "select upass from users where uname = '"+name+"'";
        String sql3 = "select steps from step where steps = '"+step+"'";
        if(!SDBManager.getOne(sql).isEmpty()){
            if(!SDBManager.getOne(sql2).isEmpty()){
                this.dispose();
                JOptionPane.showMessageDialog(this,""+sd.getDate()+"","问题",3);
                if(jComboBox1.getSelectedItem().equals("主管")){
                    PMainMenu pmainnenu = new PMainMenu();//调用主界面
                    Thread thr = new Thread(pmainnenu);
                    thr.start();
                    return;
                }
                if(jComboBox1.getSelectedItem().equals("职员")){
                    ESMainMenu emainnenu = new ESMainMenu();//调用主界面
                    Thread thr = new Thread(emainnenu);
                    thr.start();
                    return;
                }
                SMainMenu smainnenu = new SMainMenu();//调用主界面
                Thread thr = new Thread(smainnenu);
                thr.start();
                return;
            }
        }else{
            count++;
            JOptionPane.showMessageDialog(this,"        提示(登陆只有3次机会)\n"+
                                          "                 第("+count+")次\n"+
                                          "帐号不存在或密码错误,请重新填写","登陆消息",0);
            if(count > 2){
                JOptionPane.showMessageDialog(this,"严重怀疑你是不是在暴力破解本软件,拒绝访问!","警告消息",3);
                this.dispose();
            }
            jTextField1.setText("");
            jPasswordField1.setText("");
            jTextField1.requestFocus(true);
            return;
        }
    }

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

    public void jPanel1_mouseClicked(MouseEvent e) {
        int num = (int)Math.round(Math.random()*8);
        ImageIcon image=new ImageIcon("/Jewelry/logo/jew_"+num+".jpg");
        jLabel11.setIcon(image);
    }
}

class SLoginMenu_jPanel1_mouseAdapter extends MouseAdapter {
    private SLoginMenu adaptee;
    SLoginMenu_jPanel1_mouseAdapter(SLoginMenu adaptee) {
        this.adaptee = adaptee;
    }

    public void mouseClicked(MouseEvent e) {
        adaptee.jPanel1_mouseClicked(e);
    }
}


class SLoginMenu_jButton2_actionAdapter implements ActionListener {
    private SLoginMenu adaptee;
    SLoginMenu_jButton2_actionAdapter(SLoginMenu adaptee) {
        this.adaptee = adaptee;
    }

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


class SLoginMenu_jButton1_actionAdapter implements ActionListener {
    private SLoginMenu adaptee;
    SLoginMenu_jButton1_actionAdapter(SLoginMenu adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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