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

📄 loginframe.java~141~

📁 JAVA+SQL2000 网吧上下机管理
💻 JAVA~141~
字号:
package netbar;

import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.sql.SQLException;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class loginFrame extends JFrame {
    JPanel jPanel1 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JComboBox jComboBox1 = new JComboBox();
    JPasswordField jPasswordField1 = new JPasswordField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    BorderLayout borderLayout1 = new BorderLayout();
    public loginFrame() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(borderLayout1);
        setSize(new Dimension(390, 290));
        setTitle("登陆");
        setIconImage(Toolkit.getDefaultToolkit().createImage(netbar.mainFrame.class.getResource("login.png")));
        jButton2.addMouseListener(new loginFrame_jButton2_mouseAdapter(this));
        connectSQL c=new connectSQL();
        java.sql.ResultSet ts=c.s.executeQuery("select * from manager");
        while(ts.next()){
        jComboBox1.addItem(ts.getString(2));
        }
        c.closeSQL();
        jComboBox1.setFont(new java.awt.Font("宋体", Font.PLAIN, 11));
        jComboBox1.setBorder(BorderFactory.createLineBorder(Color.black));
        jComboBox1.setBounds(new Rectangle(121, 129, 198, 20));
        jButton1.addMouseListener(new loginFrame_jButton1_mouseAdapter(this));
        jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 30));
        jLabel1.setForeground(Color.red);
        jLabel1.setText("SunnyNetbar");
        jLabel1.setBounds(new Rectangle(27, 32, 270, 35));
        jLabel2.setFont(new java.awt.Font("宋体", Font.BOLD, 24));
        jLabel2.setText("System");
        jLabel2.setBounds(new Rectangle(241, 70, 78, 29));
        jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
        jLabel3.setText("登陆账号:");
        jLabel3.setBounds(new Rectangle(48, 134, 70, 16));
        jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
        jLabel4.setText("账号密码:");
        jLabel4.setBounds(new Rectangle(48, 171, 70, 16));
        jPasswordField1.setText("jPasswordField1");
        jPasswordField1.setBounds(new Rectangle(121, 168, 198, 19));
        jButton1.setBounds(new Rectangle(95, 215, 57, 23));
        jButton1.setText("确定");
        jButton2.setBounds(new Rectangle(213, 215, 57, 23));
        jButton2.setText("取消");
        this.getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
        jPanel1.add(jLabel4, null);
        jPanel1.add(jPasswordField1, null);
        jPanel1.add(jButton1, null);
        jPanel1.add(jButton2, null);
        jPanel1.add(jLabel1, null);
        jPanel1.add(jLabel2, null);
        jPanel1.add(jComboBox1, null);
        jPanel1.add(jLabel3, null);
        jPanel1.setLayout(null);
    }

    public void jButton2_mouseClicked(MouseEvent e) {
        if(e.getButton()==e.BUTTON1){
                    System.exit(0);
        }
    }

    public void jButton1_mouseClicked(MouseEvent e) throws SQLException {
        if(e.getButton()==e.BUTTON1){
        connectSQL t=new connectSQL();
        char[]   cPassword   =   jPasswordField1.getPassword();
        String Password  =  String.valueOf(cPassword);
        if(t.denglu(jComboBox1.getSelectedItem().toString().trim(),Password)){
          SwingUtilities.invokeLater(new Runnable() {
          public void run() {
               try {
                   UIManager.setLookAndFeel(UIManager.
                                            getSystemLookAndFeelClassName());
                } catch (Exception exception) {
                    exception.printStackTrace();
                }
             new mainProgram(jComboBox1.getSelectedItem().toString().trim());
            }
        });
        this.dispose();
        } else{
         JOptionPane.showMessageDialog(this,"密码错误!","验证",JOptionPane.ERROR_MESSAGE);
        }
        }
    }
}

class loginFrame_jButton2_mouseAdapter extends MouseAdapter {
    private loginFrame adaptee;
    loginFrame_jButton2_mouseAdapter(loginFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void mouseClicked(MouseEvent e) {
        adaptee.jButton2_mouseClicked(e);

    }
}


class loginFrame_jButton1_mouseAdapter extends MouseAdapter {
    private loginFrame adaptee;
    loginFrame_jButton1_mouseAdapter(loginFrame adaptee) {
        this.adaptee = adaptee;
    }

     public void mouseClicked(MouseEvent e)  {
         try {
              adaptee.jButton1_mouseClicked(e);
          } catch (SQLException ex) {
          }

    }
}

⌨️ 快捷键说明

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