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

📄 netbarfrmlogin.java

📁 一个简单的机房管理系统 可以简单的实现查询,计费 上下机,充值等功能
💻 JAVA
字号:
package src.netbar;

import java.awt.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import java.sql.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import src.Bean.MainLoginBean;
import src.Rule.MainLoginRule;
import src.Rule.Sound;

/**
 * 这是管理员登陆窗口。
 */
public class NetBarFrmLogin
    extends JFrame {
  JPanel contentPane;
  JLabel statusBar = new JLabel();
  JLabel labMainTitle = new JLabel();
  JLabel labMainUser = new JLabel();
  JLabel labMainPwd = new JLabel();
  JTextField txtMainLogin = new JTextField();
  JButton butMainOK = new JButton();
  JButton butMainRes = new JButton();
  JPasswordField txtMainPwd = new JPasswordField();
  MainLoginBean objMainLoginBean = new MainLoginBean();
  MainLoginRule objMainLoginRule;

  public NetBarFrmLogin() {
    try {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  private void jbInit() throws Exception {

    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(null);
    this.setResizable(false);
    this.setBounds(440, 250, 570, 390);
    setSize(new Dimension(400, 300));
    setTitle("机房管理系统");
    statusBar.setText(" ");
    statusBar.setBounds(new Rectangle(0, 284, 400, 16));
    labMainTitle.setFont(new java.awt.Font("黑体", Font.PLAIN, 25));
    labMainTitle.setForeground(Color.blue);
    labMainTitle.setText("管理员登陆");
    labMainTitle.setBounds(new Rectangle(125, 35, 180, 25));
    labMainUser.setFont(new java.awt.Font("Dialog", Font.PLAIN, 18));
    labMainUser.setText("帐号");
    labMainUser.setBounds(new Rectangle(79, 94, 44, 34));
    labMainPwd.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
    labMainPwd.setText("密码");
    labMainPwd.setBounds(new Rectangle(79, 136, 40, 28));
    txtMainLogin.setText("");
    txtMainLogin.setBounds(new Rectangle(146, 99, 124, 19));
    butMainOK.setBounds(new Rectangle(94, 194, 69, 24));
    butMainOK.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
    butMainOK.setText("确定");
    butMainOK.addActionListener(new NetBarFrmLogin_butMainOK_actionAdapter(this));
    butMainRes.setBounds(new Rectangle(213, 193, 68, 25));
    butMainRes.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
    butMainRes.setText("重填");
    butMainRes.addActionListener(new NetBarFrmLogin_butMainRes_actionAdapter(this));
    txtMainPwd.setText("");
    txtMainPwd.setBounds(new Rectangle(146, 135, 124, 19));
    contentPane.add(statusBar, null);
    contentPane.add(labMainTitle);
    contentPane.add(labMainUser);
    contentPane.add(labMainPwd);
    contentPane.add(txtMainLogin);
    contentPane.add(butMainOK);
    contentPane.add(butMainRes);
    contentPane.add(txtMainPwd);
    objMainLoginRule = new MainLoginRule();
    MainLoginRule obj = new MainLoginRule();
  }

  public void butMainRes_actionPerformed(ActionEvent e) {
    this.txtMainLogin.setText("");
    this.txtMainPwd.setText("");
  }

  public void butMainOK_actionPerformed(ActionEvent e) {
    String textMainLogin = this.txtMainLogin.getText();
    char PassWord[] = this.txtMainPwd.getPassword();
    String textMainPwd = String.valueOf(PassWord);
    objMainLoginBean.setUsername(textMainLogin);
    objMainLoginBean.setPassword(textMainPwd);
    if ( (textMainLogin.length() == 0) && (textMainPwd.length() == 0)) {

      JOptionPane.showMessageDialog(this, "管理员帐号或密码不能为空", "提示",
                                    JOptionPane.PLAIN_MESSAGE,
                                    new ImageIcon("imags\\shualai.gif"));
    }
    else {
      try {

        if (objMainLoginRule.MainLoginChick(objMainLoginBean)) {
          JOptionPane.showMessageDialog(this, "管理员登陆成功!!", "提示",
                                        JOptionPane.PLAIN_MESSAGE,
                                        new ImageIcon("imags\\gongxi.gif"));
          NetBarFrm objNetBarFrm = new NetBarFrm();
          objNetBarFrm.show();
          this.dispose();
          Sound.Sound("denglu");
        }
        else {
          JOptionPane.showMessageDialog(this, "管理员密码不正确!!", "提示",
                                        JOptionPane.PLAIN_MESSAGE,
                                        new ImageIcon("imags\\daizi.gif"));
        }
      }
      catch (HeadlessException ex) {
      }
      catch (SQLException ex) {
      }

    }
  }
}

class NetBarFrmLogin_butMainOK_actionAdapter
    implements ActionListener {
  private NetBarFrmLogin adaptee;
  NetBarFrmLogin_butMainOK_actionAdapter(NetBarFrmLogin adaptee) {
    this.adaptee = adaptee;
  }

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

class NetBarFrmLogin_butMainRes_actionAdapter
    implements ActionListener {
  private NetBarFrmLogin adaptee;
  NetBarFrmLogin_butMainRes_actionAdapter(NetBarFrmLogin adaptee) {
    this.adaptee = adaptee;
  }

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

⌨️ 快捷键说明

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