zoukankan      html  css  js  c++  java
  • 再来一次atm机 用文本做的

    package BAIBAI;

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.FileReader;
    import java.util.Properties;

    import javax.swing.JFrame;
    import javax.swing.JOptionPane;

    import BAOBAO.Mybutton;
    import BAOBAO.Txt;

    public class login extends JFrame{
    private Txt nametxt=new Txt("用户名", 50, 50, this);
    private Txt pwdtxt=new Txt("密码", 50, 100, this);
    private int count;
    /**
    * 创建资源对象
    */
    public static Properties pr=new Properties();
    static{
    try{
    pr.load(new FileReader("Atm.txt"));
    }
    catch(Exception e){
    System.out.println("文件未找到");
    }
    }
    public login(){
    this.setLayout(null);
    Mybutton mm=new Mybutton("登陆", 70, 180, this);
    Mybutton qq=new Mybutton("取消", 70, 240, this);
    mm.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
    /**
    * 获得文本框里面的文本
    */
    String x=nametxt.getText();
    String y=pwdtxt.getText();
    /**
    * 获得资源文件里面的文本
    */
    String filename=pr.getProperty("username");
    String filepwd=pr.getProperty("pwd");
    if(x.equals(filename)&&y.equals(filepwd)){
    JOptionPane.showMessageDialog(null, "登陆成功");
    login.this.dispose();
    Newframe n=new Newframe();
    }else{
    JOptionPane.showMessageDialog(null, "登陆失败");
    }
    count++;
    if(count>3){
    JOptionPane.showMessageDialog(null, "非法用户");
    System.exit(0);
    }
    }
    });

    qq.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
    JOptionPane.showMessageDialog(null, "谢谢使用,再见");
    System.exit(0);
    }
    });
    this.setSize(400,500 );
    this.setVisible(true);
    this.setDefaultCloseOperation(3);
    this.setLocationRelativeTo(null);
    }


    public static void main(String[] args) {
    login l=new login();

    }

    }

  • 相关阅读:
    Redis从入门到精通:初级篇(转)
    Spring配置中的"classpath:"与"classpath*:"的区别研究(转)
    maven常用命令
    JUC-线程池调度-ScheduledThreadPool
    JUC-线程池
    JUC-线程八锁
    JUC-ReadWriteLock
    JUC-Condition和Lock实践-线程按序交替执行
    Linux 查看.so中导出函数
    nginx配置反向代理
  • 原文地址:https://www.cnblogs.com/oushiyang/p/5366304.html
Copyright © 2011-2022 走看看