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

📄 loginframe.java

📁 超市管理系统 运行环境JDK1.4以上 JB2006 源代码公开
💻 JAVA
字号:
package com.aptech.view;

import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import com.aptech.classmarket.*;
import java.io.IOException;

public class LoginFrame
    extends JFrame {
  JPanel contentPane;
  JLabel lbl1 = new JLabel();
  JLabel lbl2 = new JLabel();
  JTextField jTextField1 = new JTextField();
  JPasswordField jPasswordField1 = new JPasswordField();
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JTextField jTextField2 = new JTextField();
    JLabel jLabel4 = new JLabel();
    JOptionPane jop = new JOptionPane();
    JButton jButton3 = new JButton();
    public LoginFrame() {
    try {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }
  public String yzen(){
        Yanzhenma yhm = new Yanzhenma();
        OutputStream os = null;
        try {
            os = new FileOutputStream("051219033645682.jpg");
        } catch (FileNotFoundException ex) {
        }
        String str = yhm.getMap(62, 15, os);
        return str;

  }
  /**
   * Component initialization.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {
    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(null);
    this.getContentPane().setBackground(new Color(255, 168, 255));
    setSize(new Dimension(300,250));
    setTitle("用户登陆");
        lbl1.setText("用户名称:");
    lbl1.setBounds(new Rectangle(54, 49, 69, 23));
    lbl2.setText("用户密码:");
    lbl2.setBounds(new Rectangle(54, 83, 66, 24));
    jTextField1.setBounds(new Rectangle(134, 50, 101, 22));
    jPasswordField1.setBounds(new Rectangle(134, 87, 101, 21));
    jButton1.setBackground(Color.cyan);
    jButton1.setBounds(new Rectangle(53, 177, 72, 24));
    jButton1.setText("登陆");
        jButton1.addActionListener(new LoginFrame_jButton1_actionAdapter(this));
        jButton2.setBackground(Color.cyan);
    jButton2.setBounds(new Rectangle(158, 176, 72, 25));
    jButton2.setText("退出");
    jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 20));
    jLabel1.setForeground(Color.red);
    jLabel1.setText("好又多");
    jLabel1.setBounds(new Rectangle(62, 15, 74, 26));
    jLabel2.setFont(new java.awt.Font("宋体", Font.BOLD, 20));
    jLabel2.setText("超市管理");
    jLabel2.setBounds(new Rectangle(138, 14, 111, 28));
        jLabel3.setText("验证码:");
        jLabel3.setBounds(new Rectangle(54, 121, 67, 24));
        jTextField2.setBounds(new Rectangle(134, 122, 101, 22));
        jLabel4.setFont(new java.awt.Font("黑体", Font.PLAIN, 14));
        jLabel4.setBounds(new Rectangle(243, 124, 48, 17));
        jop.setBounds(new Rectangle(216, 275, 49, 14));
        jButton3.setBounds(new Rectangle(242, 86, 29, 22));
        jButton3.setText("软");
        jButton3.addActionListener(new LoginFrame_jButton3_actionAdapter(this));
        contentPane.add(lbl1);
        contentPane.add(jPasswordField1);
        contentPane.add(jTextField1);
    contentPane.add(lbl2);
        contentPane.add(jLabel2);
    contentPane.add(jLabel1);
        contentPane.add(jButton1);
        contentPane.add(jButton2);
        contentPane.add(jLabel3);
        contentPane.add(jLabel4);
        contentPane.add(jTextField2);
        contentPane.add(jop);
        contentPane.add(jButton3);
        jLabel4.setText(yzen());
    }

    public void jButton1_actionPerformed(ActionEvent e) {
        Selectlogin ss=new Selectlogin();
        boolean flag=false;
        flag=ss.select(jTextField1.getText(),String.valueOf(jPasswordField1.getPassword()));
        if(flag==true&&jLabel4.getText().equals(jTextField2.getText())==true){
            CheckFrame cc = new CheckFrame(jTextField1.getText());
            cc.setSize(300, 150);
            cc.setVisible(true);
            this.dispose();
            cc.setLocationRelativeTo(this);
        }
        else if(flag==false&&jLabel4.getText().equals(jTextField2.getText())==true){
            jop.showMessageDialog(this, "用户名密码错误", "系统提示",
                                  JOptionPane.ERROR_MESSAGE);
            jLabel4.setText(yzen());
        }
        else if(flag==true&&jLabel4.getText().equals(jTextField2.getText())==false){
            jop.showMessageDialog(this, "验证玛错误", "系统提示",
                                  JOptionPane.ERROR_MESSAGE);
            jLabel4.setText(yzen());
        }
        else{
            jop.showMessageDialog(this, "用户名密码错误", "系统提示",
                                  JOptionPane.ERROR_MESSAGE);
            jLabel4.setText(yzen());
        }
    }

    public void jButton3_actionPerformed(ActionEvent e) {
        Runtime aa=Runtime.getRuntime();
       try {
           aa.exec("C:\\WINDOWS\\system32\\osk.exe");
       } catch (IOException ex) {
       }

    }
}


class LoginFrame_jButton3_actionAdapter implements ActionListener {
    private LoginFrame adaptee;
    LoginFrame_jButton3_actionAdapter(LoginFrame adaptee) {
        this.adaptee = adaptee;
    }

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


class LoginFrame_jButton1_actionAdapter implements ActionListener {
    private LoginFrame adaptee;
    LoginFrame_jButton1_actionAdapter(LoginFrame adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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